Discrepancy between the size of the object returned by the sos.dll file and the size of memory in memory

I used the following sos command to list all instances of a specific type in a running asp application (hosted on Windows XP 4 GB).

.foreach (obj { !dumpheap -type ::my type:: -short ::start of address space:: ::end of address space:: }) { !objsize ${obj} }.

This lists all objects of a given type in gc gen2.

The size of an object is on average about 500 KB, and about 2000 objects. That alone is about 1 GB of memory, while my asp-process memory in the task manager only shows about 700 MB. Another point is that I did not consider other loaded objects that I use.

Also, all of the above objects are root objects that will not be garbage collected. Not sure if this command is incorrect or is there any other explanation for this discrepancy in the size that sos returns and what is displayed in the task manager?

Thanks in advance,
Bharat K.

+3
source share
1 answer

!objsize , , , , , , . , , , , , , . , . , .

class SomeType {
    private readonly string Text;

    public SomeType(string text) {
        Text = text;
    }
}

var st1 = new SomeType("this is a long string that will be stored only once due to interning");
var st2 = new SomeType("this is a long string that will be stored only once due to interning");

WinDbg

0:006> !dumpheap -type Some
 Address       MT     Size
00ceb44c 00b738a8       12     
00ceb458 00b738a8       12     

0:006> !objsize 00ceb44c
sizeof(00ceb44c) =          164 (        0xa4) bytes (TestApp.SomeType)
0:006> !objsize 00ceb458
sizeof(00ceb458) =          164 (        0xa4) bytes (TestApp.SomeType)

0:006> !DumpObj 00ceb44c
Name:        TestApp.SomeType
MethodTable: 00b738a8
EEClass:     00b714bc
Size:        12(0xc) bytes
File:        c:\dev2010\FSharpLib\TestApp\bin\Release\TestApp.exe
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79b9d2b8  4000001        4        System.String  0 instance 00ceb390 Text
0:006> !DumpObj 00ceb458
Name:        TestApp.SomeType
MethodTable: 00b738a8
EEClass:     00b714bc
Size:        12(0xc) bytes
File:        c:\dev2010\FSharpLib\TestApp\bin\Release\TestApp.exe
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79b9d2b8  4000001        4        System.String  0 instance 00ceb390 Text

!dumpobj, , , , !objsize , .

+3

Source: https://habr.com/ru/post/1734012/


All Articles