microsoft / clrmd

Microsoft.Diagnostics.Runtime is a set of APIs for introspecting processes and dumps.
MIT License
1.05k stars 255 forks source link

ClrMD 2.0 reports less number of heap objects than ClrMD 1.1 on a 32-bit dump #887

Closed catstrike closed 12 months ago

catstrike commented 3 years ago

I have a dump of the 32-bit application. When I enumerate the heap objects with method heap.EnumerateObjects(), I get different results when using ClrMD 1.1 and ClrMD 2.0.

With ClrMD 1.1, I'm getting 30 666 651 objects. The same number I can get with WinDbg. ClrMD 2.0 shows me almost three times fewer objects — 11 814 763.

Kompiler commented 3 years ago

I'm also seeing this on 64-bit dumps.

For ClrMD 1.1.142101

var target = DataTarget.LoadCrashDump( @"F:\w3wp.exe.dmp" )

var clr = target.ClrVersions [ 0 ];

var runtime = clr.CreateRuntime( );

var rootCount = runtime.Heap.EnumerateRoots( ).Count( );
var objectCount = runtime.Heap.EnumerateObjects( ).Count( );

For ClrMD 2.0.161401

var target = DataTarget.LoadDump( @"F:\w3wp.exe.dmp" );

var clr = target.ClrVersions[ 0 ];

using ( var runtime = clr.CreateRuntime( ) )
{
    var rootCount = runtime.Heap.EnumerateRoots( ).Count();
    var objectCount = runtime.Heap.EnumerateObjects( ).Count( );
}

Testing on 3 different dump files:

ClrMD 1.1.142101
================

Dump        Runtime         Root Count      Object Count
----------------------------------------------------------------------------
A       4.7.3701.00     11762           106388187
B       4.8.4311.00     12364           137758778
C       4.8.4311.00     12859           134561991

ClrMD 2.0.161401
================

Dump        Runtime         Root Count      Object Count
----------------------------------------------------------------------------
A       4.7.3701.00     1251            106388187
B       4.8.4311.00     0           1062
C       4.8.4311.0      0           808
leculver commented 3 years ago

Is there a test dump I could use to reproduce this?

leculver commented 12 months ago

I am closing this issue. Without a dump or repro I could not make progress here. As far as I know, ClrMD 3.1 accurately reports all objects. Feel free to open a new issue or reply back here if there is a specific example that I should take a look at. Thanks!