Skip to content

Commit 69d0aae

Browse files
author
Christophe Nasarre
committed
Accept output from "MT Count TotalSize Class Name"; no need to include "!dumpheap -stat"
1 parent 8f5491e commit 69d0aae

File tree

3 files changed

+31
-40
lines changed

3 files changed

+31
-40
lines changed

src/LeakShell/HeapSnapshotFactory.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class HeapSnapshotFactory
1010
{
1111
private static readonly InvalidOperationException InvalidFormatException =
1212
new InvalidOperationException(
13-
"Invalid !heapstat -stat list format.\r\n Don't forget to copy the whole output; including the final \"Total ... objects\" line.");
13+
"Invalid !heapstat -stat list format.\r\n Don't forget to copy the whole output starting from \"MT Count TotalSize Class Name\"; including the final \"Total ... objects\" line.");
1414

1515
/*
1616
!dumpheap -stat
@@ -26,6 +26,8 @@ 5fc06c28 7111 300980 System.Object[]
2626
5fc4f9ac 6581 381508 System.String
2727
Total 46832 objects
2828
*/
29+
30+
private const string Header = "MT Count TotalSize Class Name";
2931
public static HeapSnapshot CreateFromHeapStat(string dumpheap)
3032
{
3133
// sanity checks
@@ -34,7 +36,7 @@ public static HeapSnapshot CreateFromHeapStat(string dumpheap)
3436
throw InvalidFormatException;
3537
}
3638

37-
if (!dumpheap.Contains("!dumpheap -stat"))
39+
if (!dumpheap.Contains(Header))
3840
{
3941
throw InvalidFormatException;
4042
}
@@ -57,20 +59,7 @@ public static HeapSnapshot CreateFromHeapStat(string dumpheap)
5759
switch (state)
5860
{
5961
case DumpHeapParsingState.Init:
60-
if (line.Contains("!dumpheap -stat"))
61-
{
62-
state = DumpHeapParsingState.Comment;
63-
}
64-
break;
65-
66-
case DumpHeapParsingState.Comment:
67-
/*
68-
PDB symbol for clr.dll not loaded
69-
total 0 objects
70-
Statistics:
71-
MT Count TotalSize Class Name
72-
*/
73-
if (line.TrimStart().StartsWith("MT"))
62+
if (line.Contains(Header))
7463
{
7564
state = DumpHeapParsingState.TypeEntries;
7665
}
@@ -300,7 +289,6 @@ private static string GetNumberFromString(string field)
300289
enum DumpHeapParsingState
301290
{
302291
Init = 0,
303-
Comment,
304292
TypeEntries,
305293
End,
306294
Error,

src/LeakShell/MainFrame.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -440,31 +440,32 @@ private string GetExceptionMessages(Exception x)
440440

441441

442442
private void SetReferenceSnapshot(HeapSnapshot snapshot)
443-
{
444-
// sanity checks
445-
if (snapshot == null)
446-
{
447-
return;
448-
}
443+
{
444+
// sanity checks
445+
if (snapshot == null)
446+
{
447+
return;
448+
}
449449

450-
// remove current "reference" item
451-
SnapshotListViewItem referenceItem = GetSnapshotItem(SnapshotListViewItemState.Reference);
452-
if (referenceItem != null)
453-
{
454-
referenceItem.State = SnapshotListViewItemState.None;
450+
// remove current "reference" item
451+
SnapshotListViewItem referenceItem = GetSnapshotItem(SnapshotListViewItemState.Reference);
452+
if (referenceItem != null)
453+
{
454+
referenceItem.State = SnapshotListViewItemState.None;
455455

456-
referenceItem.ImageIndex = -1;
457-
// Note: the item must be redrawn when the image is reset to -1
458-
lvSnapshots.RedrawItems(referenceItem.Index, referenceItem.Index, "force redraw" == null);
459-
}
456+
referenceItem.ImageIndex = -1;
457+
// Note: the item must be redrawn when the image is reset to -1
458+
lvSnapshots.RedrawItems(referenceItem.Index, referenceItem.Index, "force redraw" == null);
459+
}
460460

461-
// update the new "reference" item
462-
SnapshotListViewItem item = GetSnapshotItem(snapshot);
463-
item.State = SnapshotListViewItemState.Reference;
464-
item.ImageIndex = ReferenceImageIndex;
461+
// update the new "reference" item
462+
SnapshotListViewItem item = GetSnapshotItem(snapshot);
463+
item.State = SnapshotListViewItemState.Reference;
464+
item.ImageIndex = ReferenceImageIndex;
465+
466+
_reference = snapshot;
467+
}
465468

466-
_reference = snapshot;
467-
}
468469
private void SetCurrentSnapshot(HeapSnapshot snapshot)
469470
{
470471
// sanity checks

src/LeakShell/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.5.0.0")]
35-
[assembly: AssemblyFileVersion("1.5.0.0")]
34+
[assembly: AssemblyVersion("1.5.1.0")]
35+
[assembly: AssemblyFileVersion("1.5.1.0")]
36+
//
37+
// 1.5.1 : no need to have "!dumpheap -stat" in the text, only the "MT Count TotalSize Class Name" header
3638
//
3739
// 1.5.0 : [BUG] check for invalid "!dumpheap -stat" from clipboard
3840
// remove dump file drag & drop with COM objects installed with DebugDiag: it is now implemented with ClrMD

0 commit comments

Comments
 (0)