2014-10-30 1 views
0

Visual Studio Ultimate의 '디버그 관리 메모리 (Debug Managed Memory)'옵션에 표시된 요약과 유사한 WINDBG의 힙에 관리 대상 개체에 대한 요약 정보를 얻을 수 있습니까?windbg에서 Visual Studio 궁극적 인 "디버그 관리 메모리"출력 받기

정보를 얻을 수는 있지만 상황에 따라 다르며 매우 지루합니다. WINDBG를 사용하여 유사한 출력을 생성 할 수있는 매크로 또는 명령 집합이 있습니까?

Visual Studio는 모든 루트를 수집하고 루트 개체 클래스와 총 메모리 요약을 보여주는 아주 간단한 루틴을 갖고있는 것 같습니다.

+0

관련 : http://stackoverflow.com/questions/25247149/can-debugdiag-generate-reports-with-inclusive-size-like-visual-studio-2013/25915022#25915022 –

답변

0

처럼 모든 .NET 문제에 대한, 먼저 당신이 할 수있는, 포괄적 크기를 얻으려면

!dumpheap -stat; * Statistics output, good if you don't know what you're looking for 
!dumpheap -type <SubstringOfClass>; * If you know what type you're after 
!dumpheap -mt <MethodTable>; * If the class substring is not unique enough 

를 사용하여 당신은 다음 개체의 목록을 얻을 수 있습니다

.loadby sos clr; .loadby sos mscorwks 

SOS 확장이 필요합니다

를 사용하여 개체의 뿌리를 찾으려면

!objsize <address> 

를 사용 0

!gcroot <address> 

IMHO에는 모든 루트 개체를 표시하는 편리한 방법이 없습니다.

Visual Studio에서 개체를 스택에 나열하는지 잘 모르겠습니다.

0:005> !dumpheap -stat 
Statistics: 
       MT Count TotalSize Class Name 
000007fef2611ec8  1   24 System.Collections.Generic.ObjectEqualityComparer`1[[System.Runtime.Serialization.MemberHolder, mscorlib]] 
... 
000007fef2622968  1   64 System.BaseConfigHandler+CreateAttributeCallback 
... 
000007fef25fa690  396  117910 System.Byte[] 
000007fef25a4458  1570  227560 System.Object[] 
000007fef25f6508  3300  234762 System.String 
Total 17883 objects 

0:005> !dumpheap -stat -type Handler 
Statistics: 
       MT Count TotalSize Class Name 
000007fef2622968  1   64 System.BaseConfigHandler+CreateAttributeCallback 
000007fef26228b0  1   64 System.BaseConfigHandler+CreateNodeCallback 
000007fef26227f8  1   64 System.BaseConfigHandler+ErrorCallback 
Total 3 objects 

0:005> !dumpheap -mt 000007fef2622968 
     Address    MT  Size 
0000000002594848 000007fef2622968  64  

Statistics: 
       MT Count TotalSize Class Name 
000007fef2622968  1   64 System.BaseConfigHandler+CreateAttributeCallback 
Total 1 objects 

0:005> !objsize 0000000002594848 
sizeof(0000000002594848) = 168728 (0x29318) bytes (System.BaseConfigHandler+CreateAttributeCallback) 

0:005> !gcroot 0000000002594848 
Found 0 unique roots (run '!GCRoot -all' to see all roots). 

0:005> !gcroot -all 0000000002594848 
Found 0 roots. 

는 그래서이 객체의 참조가없는 쓰레기가 다음 GC에서 수집 될 것으로 보인다 WinDbg는 이것은

~*e !dso 

예 연습이 될 것입니다.

0:001> !dso 
OS Thread Id: 0xb2c (1) 
RSP/REG   Object   Name 
00000000024B0000 00000000024b1048 System.Exception 
0

이 당신에게 특정 유형의 관리 메모리, 힙 요약 및 힙 소비를 얻을 것 그냥 경우에 당신은 힙에 문자열을 찾기 위해 노력하고 있습니다 :

!EEHeap 
!DumpHeap -stat 
!DumpHeap -strings 
!DumpHeap -Type <TypeSpec> 

이 당신이 bin 파일을 드릴 것입니다을하는 CLRProfiler에서 사용할 수 있습니다 : 더 SOS Help를 참조하십시오

!traverseheap 

.sosex는 또 다른 확장이지만 누수를 디버그하는 데 사용하지 않았습니다. CLRProfiler 및 Visual Studio 독립형 프로파일 러는 Windbg IMHO보다 이러한 문제를 디버깅하는 데 가장 적합한 도구입니다.