dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.76k forks source link

How do I get the distribution of application memory in Windbg #62626

Open hueifeng opened 2 years ago

hueifeng commented 2 years ago

In address -summary, I found inside MEM_COMMIT to 4.423 GB, but I can only get in eeheap 405618688 bytes, I passed! Heap -s can get the memory is very small.Memory. Now I don't know, how can I investigate the remaining memory of MEM COMMIT .

How can I see how these memory spilled?Usually I can use! Heap -s to see the disclosure issues of Windows NT, but I can't see it in this.

!address -summary MEM_COMMIT 4.423 GB

0:000> !address -summary

--- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
Free                                    579     7df9`74541000 ( 125.974 TB)           98.42%
<unknown>                               912      206`7c9dc000 (   2.025 TB)  99.99%    1.58%
Image                                   972        0`06a01000 ( 106.004 MB)   0.00%    0.00%
Heap                                     81        0`05a27000 (  90.152 MB)   0.00%    0.00%
Stack                                   114        0`02a80000 (  42.500 MB)   0.00%    0.00%
Other                                     9        0`001de000 (   1.867 MB)   0.00%    0.00%
TEB                                      38        0`0004c000 ( 304.000 kB)   0.00%    0.00%
PEB                                       1        0`00001000 (   4.000 kB)   0.00%    0.00%

--- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_MAPPED                              220      200`062b0000 (   2.000 TB)  98.74%    1.56%
MEM_PRIVATE                             935        6`7edfe000 (  25.982 GB)   1.25%    0.02%
MEM_IMAGE                               972        0`06a01000 ( 106.004 MB)   0.00%    0.00%

--- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal
MEM_FREE                                579     7df9`74541000 ( 125.974 TB)           98.42%
MEM_RESERVE                             296      205`709f6000 (   2.021 TB)  99.79%    1.58%
MEM_COMMIT                             1831        1`1b0b9000 (   4.423 GB)   0.21%    0.00%

--- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal
PAGE_READWRITE                          862        1`0e1cc000 (   4.221 GB)   0.20%    0.00%
PAGE_READONLY                           579        0`0659a000 ( 101.602 MB)   0.00%    0.00%
PAGE_EXECUTE_READ                       159        0`04f2b000 (  79.168 MB)   0.00%    0.00%
PAGE_NOACCESS                            80        0`01550000 (  21.312 MB)   0.00%    0.00%
PAGE_EXECUTE_READWRITE                   19        0`002ba000 (   2.727 MB)   0.00%    0.00%
PAGE_WRITECOPY                           94        0`001aa000 (   1.664 MB)   0.00%    0.00%
PAGE_READWRITE | PAGE_GUARD              38        0`00074000 ( 464.000 kB)   0.00%    0.00%

--- Largest Region by Usage ----------- Base Address -------- Region Size ----------
Free                                    21e`6c05c000     7bd5`f48f4000 ( 123.836 TB)
<unknown>                              7dfd`d8ac0000      1f7`68898000 (   1.966 TB)
Image                                  7ff9`71121000        0`009ba000 (   9.727 MB)
Heap                                    218`83c71000        0`00eff000 (  14.996 MB)
Stack                                    22`cad80000        0`0017c000 (   1.484 MB)
Other                                   218`f1b50000        0`00181000 (   1.504 MB)
TEB                                      22`ca410000        0`00002000 (   8.000 kB)
PEB                                      22`ca40f000        0`00001000 (   4.000 kB)

!eeheap -gc 405618688 bytes.

0:000> !eeheap -gc
Number of GC Heaps: 12
------------------------------
Heap 0 (00000218F3182A40)
generation 0 starts at 0x00000218F34C9DB0
generation 1 starts at 0x00000218F3477478
generation 2 starts at 0x00000218F3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
00000218F3460000  00000218F3461000  00000218F3A0BDC8  00000218F3F02000  0x5aadc8(5942728)  0xaa1000(11145216)
Large object heap starts at 0x0000021BF3461000
         segment             begin         allocated         committed    allocated size    committed size
0000021BF3460000  0000021BF3461000  0000021BF449E8D0  0000021BF44BF000  0x103d8d0(17029328)  0x105e000(17162240)
Pinned object heap starts at 0x0000021CB3461000
0000021CB3460000  0000021CB3461000  0000021CB3464FF0  0000021CB3472000  0x3ff0(16368)  0x11000(69632)
Allocated Heap Size:       Size: 0x15ec688 (22988424) bytes.
Committed Heap Size:       Size: 0x1aff000 (28307456) bytes.
------------------------------
Heap 1 (00000218F31AE470)
generation 0 starts at 0x00000219334C05F8
generation 1 starts at 0x0000021933471E28
generation 2 starts at 0x0000021933461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021933460000  0000021933461000  0000021933A20610  0000021933EE2000  0x5bf610(6026768)  0xa81000(11014144)
Large object heap starts at 0x0000021C03461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C03460000  0000021C03461000  0000021C0451F4E8  0000021C04520000  0x10be4e8(17556712)  0x10bf000(17559552)
Pinned object heap starts at 0x0000021CC3461000
0000021CC3460000  0000021CC3461000  0000021CC3462030  0000021CC3472000  0x1030(4144)  0x11000(69632)
Allocated Heap Size:       Size: 0x167eb28 (23587624) bytes.
Committed Heap Size:       Size: 0x1b40000 (28573696) bytes.
------------------------------
Heap 2 (00000218F31DD200)
generation 0 starts at 0x00000219734967E0
generation 1 starts at 0x000002197346DFB0
generation 2 starts at 0x0000021973461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021973460000  0000021973461000  00000219734987F8  0000021973E52000  0x377f8(227320)  0x9f1000(10424320)
Large object heap starts at 0x0000021C13461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C13460000  0000021C13461000  0000021C14B631F8  0000021C14B83000  0x17021f8(24125944)  0x1722000(24256512)
Pinned object heap starts at 0x0000021CD3461000
0000021CD3460000  0000021CD3461000  0000021CD3461018  0000021CD3462000  0x18(24)  0x1000(4096)
Allocated Heap Size:       Size: 0x1739a08 (24353288) bytes.
Committed Heap Size:       Size: 0x2113000 (34680832) bytes.
------------------------------
Heap 3 (00000218F3208F70)
generation 0 starts at 0x00000219B34B7828
generation 1 starts at 0x00000219B3489AB8
generation 2 starts at 0x00000219B3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
00000219B3460000  00000219B3461000  00000219B3A17840  00000219B3EC2000  0x5b6840(5990464)  0xa61000(10883072)
Large object heap starts at 0x0000021C23461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C23460000  0000021C23461000  0000021C24B43768  0000021C24B83000  0x16e2768(23996264)  0x1722000(24256512)
Pinned object heap starts at 0x0000021CE3461000
0000021CE3460000  0000021CE3461000  0000021CE3462030  0000021CE3472000  0x1030(4144)  0x11000(69632)
Allocated Heap Size:       Size: 0x1c99fd8 (29990872) bytes.
Committed Heap Size:       Size: 0x2183000 (35139584) bytes.
------------------------------
Heap 4 (00000218F3234CE0)
generation 0 starts at 0x00000219F34DC428
generation 1 starts at 0x00000219F34730F0
generation 2 starts at 0x00000219F3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
00000219F3460000  00000219F3461000  00000219F3BAA440  00000219F3EE2000  0x749440(7640128)  0xa81000(11014144)
Large object heap starts at 0x0000021C33461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C33460000  0000021C33461000  0000021C3410D580  0000021C3412E000  0xcac580(13288832)  0xccd000(13422592)
Pinned object heap starts at 0x0000021CF3461000
0000021CF3460000  0000021CF3461000  0000021CF3465030  0000021CF3472000  0x4030(16432)  0x11000(69632)
Allocated Heap Size:       Size: 0x13f99f0 (20945392) bytes.
Committed Heap Size:       Size: 0x174e000 (24436736) bytes.
------------------------------
Heap 5 (0000021D7EDD1EF0)
generation 0 starts at 0x0000021A334F9AF8
generation 1 starts at 0x0000021A33485C40
generation 2 starts at 0x0000021A33461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021A33460000  0000021A33461000  0000021A33A59B10  0000021A33F02000  0x5f8b10(6261520)  0xaa1000(11145216)
Large object heap starts at 0x0000021C43461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C43460000  0000021C43461000  0000021C444BCE08  0000021C4451C000  0x105be08(17153544)  0x10bb000(17543168)
Pinned object heap starts at 0x0000021D03461000
0000021D03460000  0000021D03461000  0000021D03461018  0000021D03462000  0x18(24)  0x1000(4096)
Allocated Heap Size:       Size: 0x1654930 (23415088) bytes.
Committed Heap Size:       Size: 0x1b5c000 (28688384) bytes.
------------------------------
Heap 6 (0000021D7EDFD920)
generation 0 starts at 0x0000021A73495A38
generation 1 starts at 0x0000021A73469D68
generation 2 starts at 0x0000021A73461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021A73460000  0000021A73461000  0000021A73A15A50  0000021A73E92000  0x5b4a50(5982800)  0xa31000(10686464)
Large object heap starts at 0x0000021C53461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C53460000  0000021C53461000  0000021C549CAFA8  0000021C549CB000  0x1569fa8(22454184)  0x156a000(22454272)
Pinned object heap starts at 0x0000021D13461000
0000021D13460000  0000021D13461000  0000021D13461018  0000021D13462000  0x18(24)  0x1000(4096)
Allocated Heap Size:       Size: 0x1b1ea10 (28437008) bytes.
Committed Heap Size:       Size: 0x1f9b000 (33140736) bytes.
------------------------------
Heap 7 (0000021D7EE29690)
generation 0 starts at 0x0000021AB35B3700
generation 1 starts at 0x0000021AB3580548
generation 2 starts at 0x0000021AB3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021AB3460000  0000021AB3461000  0000021AB39D3718  0000021AB3FC2000  0x572718(5711640)  0xb61000(11931648)
Large object heap starts at 0x0000021C63461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C63460000  0000021C63461000  0000021C649CCBF8  0000021C649ED000  0x156bbf8(22461432)  0x158c000(22593536)
Pinned object heap starts at 0x0000021D23461000
0000021D23460000  0000021D23461000  0000021D23461018  0000021D23462000  0x18(24)  0x1000(4096)
Allocated Heap Size:       Size: 0x1ade328 (28173096) bytes.
Committed Heap Size:       Size: 0x20ed000 (34525184) bytes.
------------------------------
Heap 8 (0000021D7EE55400)
generation 0 starts at 0x0000021AF3496810
generation 1 starts at 0x0000021AF3472A28
generation 2 starts at 0x0000021AF3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021AF3460000  0000021AF3461000  0000021AF39F6828  0000021AF3E92000  0x595828(5855272)  0xa31000(10686464)
Large object heap starts at 0x0000021C73461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C73460000  0000021C73461000  0000021C7492E5F8  0000021C7494F000  0x14cd5f8(21812728)  0x14ee000(21946368)
Pinned object heap starts at 0x0000021D33461000
0000021D33460000  0000021D33461000  0000021D33461830  0000021D33462000  0x830(2096)  0x1000(4096)
Allocated Heap Size:       Size: 0x1a63650 (27670096) bytes.
Committed Heap Size:       Size: 0x1f1f000 (32632832) bytes.
------------------------------
Heap 9 (0000021D7EE81170)
generation 0 starts at 0x0000021B334DE9E0
generation 1 starts at 0x0000021B334A73C8
generation 2 starts at 0x0000021B33461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021B33460000  0000021B33461000  0000021B33A409F8  0000021B33E82000  0x5df9f8(6158840)  0xa21000(10620928)
Large object heap starts at 0x0000021C83461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C83460000  0000021C83461000  0000021C849E9DF8  0000021C84A0A000  0x1588df8(22580728)  0x15a9000(22712320)
Pinned object heap starts at 0x0000021D43461000
0000021D43460000  0000021D43461000  0000021D43461018  0000021D43462000  0x18(24)  0x1000(4096)
Allocated Heap Size:       Size: 0x1b68808 (28739592) bytes.
Committed Heap Size:       Size: 0x1fca000 (33333248) bytes.
------------------------------
Heap 10 (0000021D7EEADD80)
generation 0 starts at 0x0000021B73544EC8
generation 1 starts at 0x0000021B73504C18
generation 2 starts at 0x0000021B73461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021B73460000  0000021B73461000  0000021B73AEAEE0  0000021B73F42000  0x689ee0(6856416)  0xae1000(11407360)
Large object heap starts at 0x0000021C93461000
         segment             begin         allocated         committed    allocated size    committed size
0000021C93460000  0000021C93461000  0000021C955DEF78  0000021C955DF000  0x217df78(35118968)  0x217e000(35119104)
Pinned object heap starts at 0x0000021D53461000
0000021D53460000  0000021D53461000  0000021D53468450  0000021D53472000  0x7450(29776)  0x11000(69632)
Allocated Heap Size:       Size: 0x280f2a8 (42005160) bytes.
Committed Heap Size:       Size: 0x2c5f000 (46526464) bytes.
------------------------------
Heap 11 (0000021D7EED9980)
generation 0 starts at 0x0000021BB34C6550
generation 1 starts at 0x0000021BB34784A8
generation 2 starts at 0x0000021BB3461000
ephemeral segment allocation context: none
         segment             begin         allocated         committed    allocated size    committed size
0000021BB3460000  0000021BB3461000  0000021BB3906568  0000021BB3EA2000  0x4a5568(4871528)  0xa41000(10752000)
Large object heap starts at 0x0000021CA3461000
         segment             begin         allocated         committed    allocated size    committed size
0000021CA3460000  0000021CA3461000  0000021CA55A4DB8  0000021CA55A5000  0x2143db8(34880952)  0x2144000(34881536)
Pinned object heap starts at 0x0000021D63461000
0000021D63460000  0000021D63461000  0000021D6346CF88  0000021D63472000  0xbf88(49032)  0x11000(69632)
Allocated Heap Size:       Size: 0x25f52a8 (39801512) bytes.
Committed Heap Size:       Size: 0x2b85000 (45633536) bytes.
------------------------------
GC Allocated Heap Size:    Size: 0x14459f90 (340107152) bytes.
GC Committed Heap Size:    Size: 0x182d4000 (405618688) bytes.

!heap -s

0:000> !heap -s

************************************************************************************************************************
                                              NT HEAP STATS BELOW
************************************************************************************************************************
LFH Key                   : 0xa893144b6b979747
Termination on corruption : ENABLED
          Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                            (k)     (k)    (k)     (k) length      blocks cont. heap 
-------------------------------------------------------------------------------------
00000218f1710000 00000002   65320  14712  64928   5575   163    16    2      c   LFH
    External fragmentation  38 % (163 free blocks)
00000218f1660000 00008000      64      4     64      2     1     1    0      0      
00000218f16f0000 00001002    3516   2388   3124    200    58     3    0      0   LFH
00000218f3360000 00001002      60      8     60      2     1     1    0      0      
00000218f3450000 00041002      60      8     60      5     1     1    0      0      
0000021d7fa40000 00001002    3516   1460   3124     89    25     3    0      0   LFH
0000021d7fc00000 00001002      60      8     60      5     1     1    0      0      
0000021d7fbc0000 00001002     452     32     60      5     2     1    0      0   LFH
-------------------------------------------------------------------------------------

https://github.com/hueifeng/MemoryLeak

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 2 years ago

Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.

Issue Details
In address -summary, I found inside MEM_COMMIT to 4.423 GB, but I can only get in eeheap 405618688 bytes, I passed! Heap -s can get the memory is very small.Memory. Now I don't know, how can I investigate the remaining memory of MEM COMMIT . How can I see how these memory spilled?Usually I can use! Heap -s to see the disclosure issues of Windows NT, but I can't see it in this. !address -summary MEM_COMMIT 4.423 GB ``` 0:000> !address -summary --- Usage Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal Free 579 7df9`74541000 ( 125.974 TB) 98.42% 912 206`7c9dc000 ( 2.025 TB) 99.99% 1.58% Image 972 0`06a01000 ( 106.004 MB) 0.00% 0.00% Heap 81 0`05a27000 ( 90.152 MB) 0.00% 0.00% Stack 114 0`02a80000 ( 42.500 MB) 0.00% 0.00% Other 9 0`001de000 ( 1.867 MB) 0.00% 0.00% TEB 38 0`0004c000 ( 304.000 kB) 0.00% 0.00% PEB 1 0`00001000 ( 4.000 kB) 0.00% 0.00% --- Type Summary (for busy) ------ RgnCount ----------- Total Size -------- %ofBusy %ofTotal MEM_MAPPED 220 200`062b0000 ( 2.000 TB) 98.74% 1.56% MEM_PRIVATE 935 6`7edfe000 ( 25.982 GB) 1.25% 0.02% MEM_IMAGE 972 0`06a01000 ( 106.004 MB) 0.00% 0.00% --- State Summary ---------------- RgnCount ----------- Total Size -------- %ofBusy %ofTotal MEM_FREE 579 7df9`74541000 ( 125.974 TB) 98.42% MEM_RESERVE 296 205`709f6000 ( 2.021 TB) 99.79% 1.58% MEM_COMMIT 1831 1`1b0b9000 ( 4.423 GB) 0.21% 0.00% --- Protect Summary (for commit) - RgnCount ----------- Total Size -------- %ofBusy %ofTotal PAGE_READWRITE 862 1`0e1cc000 ( 4.221 GB) 0.20% 0.00% PAGE_READONLY 579 0`0659a000 ( 101.602 MB) 0.00% 0.00% PAGE_EXECUTE_READ 159 0`04f2b000 ( 79.168 MB) 0.00% 0.00% PAGE_NOACCESS 80 0`01550000 ( 21.312 MB) 0.00% 0.00% PAGE_EXECUTE_READWRITE 19 0`002ba000 ( 2.727 MB) 0.00% 0.00% PAGE_WRITECOPY 94 0`001aa000 ( 1.664 MB) 0.00% 0.00% PAGE_READWRITE | PAGE_GUARD 38 0`00074000 ( 464.000 kB) 0.00% 0.00% --- Largest Region by Usage ----------- Base Address -------- Region Size ---------- Free 21e`6c05c000 7bd5`f48f4000 ( 123.836 TB) 7dfd`d8ac0000 1f7`68898000 ( 1.966 TB) Image 7ff9`71121000 0`009ba000 ( 9.727 MB) Heap 218`83c71000 0`00eff000 ( 14.996 MB) Stack 22`cad80000 0`0017c000 ( 1.484 MB) Other 218`f1b50000 0`00181000 ( 1.504 MB) TEB 22`ca410000 0`00002000 ( 8.000 kB) PEB 22`ca40f000 0`00001000 ( 4.000 kB) ``` !eeheap -gc 405618688 bytes. ``` 0:000> !eeheap -gc Number of GC Heaps: 12 ------------------------------ Heap 0 (00000218F3182A40) generation 0 starts at 0x00000218F34C9DB0 generation 1 starts at 0x00000218F3477478 generation 2 starts at 0x00000218F3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 00000218F3460000 00000218F3461000 00000218F3A0BDC8 00000218F3F02000 0x5aadc8(5942728) 0xaa1000(11145216) Large object heap starts at 0x0000021BF3461000 segment begin allocated committed allocated size committed size 0000021BF3460000 0000021BF3461000 0000021BF449E8D0 0000021BF44BF000 0x103d8d0(17029328) 0x105e000(17162240) Pinned object heap starts at 0x0000021CB3461000 0000021CB3460000 0000021CB3461000 0000021CB3464FF0 0000021CB3472000 0x3ff0(16368) 0x11000(69632) Allocated Heap Size: Size: 0x15ec688 (22988424) bytes. Committed Heap Size: Size: 0x1aff000 (28307456) bytes. ------------------------------ Heap 1 (00000218F31AE470) generation 0 starts at 0x00000219334C05F8 generation 1 starts at 0x0000021933471E28 generation 2 starts at 0x0000021933461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021933460000 0000021933461000 0000021933A20610 0000021933EE2000 0x5bf610(6026768) 0xa81000(11014144) Large object heap starts at 0x0000021C03461000 segment begin allocated committed allocated size committed size 0000021C03460000 0000021C03461000 0000021C0451F4E8 0000021C04520000 0x10be4e8(17556712) 0x10bf000(17559552) Pinned object heap starts at 0x0000021CC3461000 0000021CC3460000 0000021CC3461000 0000021CC3462030 0000021CC3472000 0x1030(4144) 0x11000(69632) Allocated Heap Size: Size: 0x167eb28 (23587624) bytes. Committed Heap Size: Size: 0x1b40000 (28573696) bytes. ------------------------------ Heap 2 (00000218F31DD200) generation 0 starts at 0x00000219734967E0 generation 1 starts at 0x000002197346DFB0 generation 2 starts at 0x0000021973461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021973460000 0000021973461000 00000219734987F8 0000021973E52000 0x377f8(227320) 0x9f1000(10424320) Large object heap starts at 0x0000021C13461000 segment begin allocated committed allocated size committed size 0000021C13460000 0000021C13461000 0000021C14B631F8 0000021C14B83000 0x17021f8(24125944) 0x1722000(24256512) Pinned object heap starts at 0x0000021CD3461000 0000021CD3460000 0000021CD3461000 0000021CD3461018 0000021CD3462000 0x18(24) 0x1000(4096) Allocated Heap Size: Size: 0x1739a08 (24353288) bytes. Committed Heap Size: Size: 0x2113000 (34680832) bytes. ------------------------------ Heap 3 (00000218F3208F70) generation 0 starts at 0x00000219B34B7828 generation 1 starts at 0x00000219B3489AB8 generation 2 starts at 0x00000219B3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 00000219B3460000 00000219B3461000 00000219B3A17840 00000219B3EC2000 0x5b6840(5990464) 0xa61000(10883072) Large object heap starts at 0x0000021C23461000 segment begin allocated committed allocated size committed size 0000021C23460000 0000021C23461000 0000021C24B43768 0000021C24B83000 0x16e2768(23996264) 0x1722000(24256512) Pinned object heap starts at 0x0000021CE3461000 0000021CE3460000 0000021CE3461000 0000021CE3462030 0000021CE3472000 0x1030(4144) 0x11000(69632) Allocated Heap Size: Size: 0x1c99fd8 (29990872) bytes. Committed Heap Size: Size: 0x2183000 (35139584) bytes. ------------------------------ Heap 4 (00000218F3234CE0) generation 0 starts at 0x00000219F34DC428 generation 1 starts at 0x00000219F34730F0 generation 2 starts at 0x00000219F3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 00000219F3460000 00000219F3461000 00000219F3BAA440 00000219F3EE2000 0x749440(7640128) 0xa81000(11014144) Large object heap starts at 0x0000021C33461000 segment begin allocated committed allocated size committed size 0000021C33460000 0000021C33461000 0000021C3410D580 0000021C3412E000 0xcac580(13288832) 0xccd000(13422592) Pinned object heap starts at 0x0000021CF3461000 0000021CF3460000 0000021CF3461000 0000021CF3465030 0000021CF3472000 0x4030(16432) 0x11000(69632) Allocated Heap Size: Size: 0x13f99f0 (20945392) bytes. Committed Heap Size: Size: 0x174e000 (24436736) bytes. ------------------------------ Heap 5 (0000021D7EDD1EF0) generation 0 starts at 0x0000021A334F9AF8 generation 1 starts at 0x0000021A33485C40 generation 2 starts at 0x0000021A33461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021A33460000 0000021A33461000 0000021A33A59B10 0000021A33F02000 0x5f8b10(6261520) 0xaa1000(11145216) Large object heap starts at 0x0000021C43461000 segment begin allocated committed allocated size committed size 0000021C43460000 0000021C43461000 0000021C444BCE08 0000021C4451C000 0x105be08(17153544) 0x10bb000(17543168) Pinned object heap starts at 0x0000021D03461000 0000021D03460000 0000021D03461000 0000021D03461018 0000021D03462000 0x18(24) 0x1000(4096) Allocated Heap Size: Size: 0x1654930 (23415088) bytes. Committed Heap Size: Size: 0x1b5c000 (28688384) bytes. ------------------------------ Heap 6 (0000021D7EDFD920) generation 0 starts at 0x0000021A73495A38 generation 1 starts at 0x0000021A73469D68 generation 2 starts at 0x0000021A73461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021A73460000 0000021A73461000 0000021A73A15A50 0000021A73E92000 0x5b4a50(5982800) 0xa31000(10686464) Large object heap starts at 0x0000021C53461000 segment begin allocated committed allocated size committed size 0000021C53460000 0000021C53461000 0000021C549CAFA8 0000021C549CB000 0x1569fa8(22454184) 0x156a000(22454272) Pinned object heap starts at 0x0000021D13461000 0000021D13460000 0000021D13461000 0000021D13461018 0000021D13462000 0x18(24) 0x1000(4096) Allocated Heap Size: Size: 0x1b1ea10 (28437008) bytes. Committed Heap Size: Size: 0x1f9b000 (33140736) bytes. ------------------------------ Heap 7 (0000021D7EE29690) generation 0 starts at 0x0000021AB35B3700 generation 1 starts at 0x0000021AB3580548 generation 2 starts at 0x0000021AB3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021AB3460000 0000021AB3461000 0000021AB39D3718 0000021AB3FC2000 0x572718(5711640) 0xb61000(11931648) Large object heap starts at 0x0000021C63461000 segment begin allocated committed allocated size committed size 0000021C63460000 0000021C63461000 0000021C649CCBF8 0000021C649ED000 0x156bbf8(22461432) 0x158c000(22593536) Pinned object heap starts at 0x0000021D23461000 0000021D23460000 0000021D23461000 0000021D23461018 0000021D23462000 0x18(24) 0x1000(4096) Allocated Heap Size: Size: 0x1ade328 (28173096) bytes. Committed Heap Size: Size: 0x20ed000 (34525184) bytes. ------------------------------ Heap 8 (0000021D7EE55400) generation 0 starts at 0x0000021AF3496810 generation 1 starts at 0x0000021AF3472A28 generation 2 starts at 0x0000021AF3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021AF3460000 0000021AF3461000 0000021AF39F6828 0000021AF3E92000 0x595828(5855272) 0xa31000(10686464) Large object heap starts at 0x0000021C73461000 segment begin allocated committed allocated size committed size 0000021C73460000 0000021C73461000 0000021C7492E5F8 0000021C7494F000 0x14cd5f8(21812728) 0x14ee000(21946368) Pinned object heap starts at 0x0000021D33461000 0000021D33460000 0000021D33461000 0000021D33461830 0000021D33462000 0x830(2096) 0x1000(4096) Allocated Heap Size: Size: 0x1a63650 (27670096) bytes. Committed Heap Size: Size: 0x1f1f000 (32632832) bytes. ------------------------------ Heap 9 (0000021D7EE81170) generation 0 starts at 0x0000021B334DE9E0 generation 1 starts at 0x0000021B334A73C8 generation 2 starts at 0x0000021B33461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021B33460000 0000021B33461000 0000021B33A409F8 0000021B33E82000 0x5df9f8(6158840) 0xa21000(10620928) Large object heap starts at 0x0000021C83461000 segment begin allocated committed allocated size committed size 0000021C83460000 0000021C83461000 0000021C849E9DF8 0000021C84A0A000 0x1588df8(22580728) 0x15a9000(22712320) Pinned object heap starts at 0x0000021D43461000 0000021D43460000 0000021D43461000 0000021D43461018 0000021D43462000 0x18(24) 0x1000(4096) Allocated Heap Size: Size: 0x1b68808 (28739592) bytes. Committed Heap Size: Size: 0x1fca000 (33333248) bytes. ------------------------------ Heap 10 (0000021D7EEADD80) generation 0 starts at 0x0000021B73544EC8 generation 1 starts at 0x0000021B73504C18 generation 2 starts at 0x0000021B73461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021B73460000 0000021B73461000 0000021B73AEAEE0 0000021B73F42000 0x689ee0(6856416) 0xae1000(11407360) Large object heap starts at 0x0000021C93461000 segment begin allocated committed allocated size committed size 0000021C93460000 0000021C93461000 0000021C955DEF78 0000021C955DF000 0x217df78(35118968) 0x217e000(35119104) Pinned object heap starts at 0x0000021D53461000 0000021D53460000 0000021D53461000 0000021D53468450 0000021D53472000 0x7450(29776) 0x11000(69632) Allocated Heap Size: Size: 0x280f2a8 (42005160) bytes. Committed Heap Size: Size: 0x2c5f000 (46526464) bytes. ------------------------------ Heap 11 (0000021D7EED9980) generation 0 starts at 0x0000021BB34C6550 generation 1 starts at 0x0000021BB34784A8 generation 2 starts at 0x0000021BB3461000 ephemeral segment allocation context: none segment begin allocated committed allocated size committed size 0000021BB3460000 0000021BB3461000 0000021BB3906568 0000021BB3EA2000 0x4a5568(4871528) 0xa41000(10752000) Large object heap starts at 0x0000021CA3461000 segment begin allocated committed allocated size committed size 0000021CA3460000 0000021CA3461000 0000021CA55A4DB8 0000021CA55A5000 0x2143db8(34880952) 0x2144000(34881536) Pinned object heap starts at 0x0000021D63461000 0000021D63460000 0000021D63461000 0000021D6346CF88 0000021D63472000 0xbf88(49032) 0x11000(69632) Allocated Heap Size: Size: 0x25f52a8 (39801512) bytes. Committed Heap Size: Size: 0x2b85000 (45633536) bytes. ------------------------------ GC Allocated Heap Size: Size: 0x14459f90 (340107152) bytes. GC Committed Heap Size: Size: 0x182d4000 (405618688) bytes. ``` !heap -s ``` 0:000> !heap -s ************************************************************************************************************************ NT HEAP STATS BELOW ************************************************************************************************************************ LFH Key : 0xa893144b6b979747 Termination on corruption : ENABLED Heap Flags Reserv Commit Virt Free List UCR Virt Lock Fast (k) (k) (k) (k) length blocks cont. heap ------------------------------------------------------------------------------------- 00000218f1710000 00000002 65320 14712 64928 5575 163 16 2 c LFH External fragmentation 38 % (163 free blocks) 00000218f1660000 00008000 64 4 64 2 1 1 0 0 00000218f16f0000 00001002 3516 2388 3124 200 58 3 0 0 LFH 00000218f3360000 00001002 60 8 60 2 1 1 0 0 00000218f3450000 00041002 60 8 60 5 1 1 0 0 0000021d7fa40000 00001002 3516 1460 3124 89 25 3 0 0 LFH 0000021d7fc00000 00001002 60 8 60 5 1 1 0 0 0000021d7fbc0000 00001002 452 32 60 5 2 1 0 0 LFH ------------------------------------------------------------------------------------- ``` https://github.com/hueifeng/MemoryLeak
Author: hueifeng
Assignees: -
Labels: `question`, `area-Diagnostics-coreclr`, `untriaged`
Milestone: -
tommcdon commented 2 years ago

@Maoni0 @mikem8361 @cshung

cshung commented 2 years ago

You could try !address without the -summary flag to figure out what the individual pieces of commits are. Trying your repro locally, I could find quite a bit of module images and mapped files.

You can also try !eeheap without the -gc option to see what other heaps the CLR internally uses.

hueifeng commented 2 years ago

I don't quite understand if my application is calling virtualAlloc, but its physical memory is very high.

image

Run this Program, access to http://localhost:5000/excel, you can find that its memory has been growing, this is actually because there is no timely dispose .

For now, I'm using !finalizequeue to see, but I don't understand if I go through Windbg to check memory problems, for the program's problems can not be found in visible memory?

0:000> !finalizequeue
SyncBlocks to be cleaned up: 0
Free-Threaded Interfaces to be released: 0
MTA Interfaces to be released: 0
STA Interfaces to be released: 0
----------------------------------
------------------------------
Heap 0
generation 0 has 5 finalizable objects (000001830FEB0BA8->000001830FEB0BD0)
generation 1 has 69 finalizable objects (000001830FEB0980->000001830FEB0BA8)
generation 2 has 0 finalizable objects (000001830FEB0980->000001830FEB0980)
Ready for finalization 0 objects (000001830FEB0BD0->000001830FEB0BD0)
------------------------------
Heap 1
generation 0 has 5 finalizable objects (000001830FEB0F50->000001830FEB0F78)
generation 1 has 32 finalizable objects (000001830FEB0E50->000001830FEB0F50)
generation 2 has 0 finalizable objects (000001830FEB0E50->000001830FEB0E50)
Ready for finalization 0 objects (000001830FEB0F78->000001830FEB0F78)
------------------------------
Heap 2
generation 0 has 6 finalizable objects (000001830BEBC728->000001830BEBC758)
generation 1 has 127 finalizable objects (000001830BEBC330->000001830BEBC728)
generation 2 has 0 finalizable objects (000001830BEBC330->000001830BEBC330)
Ready for finalization 0 objects (000001830BEBC758->000001830BEBC758)
------------------------------
Heap 3
generation 0 has 11 finalizable objects (000001830BF1D170->000001830BF1D1C8)
generation 1 has 78 finalizable objects (000001830BF1CF00->000001830BF1D170)
generation 2 has 0 finalizable objects (000001830BF1CF00->000001830BF1CF00)
Ready for finalization 0 objects (000001830BF1D1C8->000001830BF1D1C8)
------------------------------
Heap 4
generation 0 has 6 finalizable objects (000001837AB892F8->000001837AB89328)
generation 1 has 55 finalizable objects (000001837AB89140->000001837AB892F8)
generation 2 has 0 finalizable objects (000001837AB89140->000001837AB89140)
Ready for finalization 0 objects (000001837AB89328->000001837AB89328)
------------------------------
Heap 5
generation 0 has 8 finalizable objects (000001887BBC6D68->000001887BBC6DA8)
generation 1 has 41 finalizable objects (000001887BBC6C20->000001887BBC6D68)
generation 2 has 0 finalizable objects (000001887BBC6C20->000001887BBC6C20)
Ready for finalization 0 objects (000001887BBC6DA8->000001887BBC6DA8)
------------------------------
Heap 6
generation 0 has 8 finalizable objects (00000183790A2A80->00000183790A2AC0)
generation 1 has 60 finalizable objects (00000183790A28A0->00000183790A2A80)
generation 2 has 0 finalizable objects (00000183790A28A0->00000183790A28A0)
Ready for finalization 0 objects (00000183790A2AC0->00000183790A2AC0)
------------------------------
Heap 7
generation 0 has 5 finalizable objects (000001830BAF04E8->000001830BAF0510)
generation 1 has 37 finalizable objects (000001830BAF03C0->000001830BAF04E8)
generation 2 has 0 finalizable objects (000001830BAF03C0->000001830BAF03C0)
Ready for finalization 0 objects (000001830BAF0510->000001830BAF0510)
Statistics for all finalizable objects (including all objects ready for finalization):
              MT    Count    TotalSize Class Name
00007ffc2dc23818        1           24 System.Net.Security.SafeCredentialReference
00007ffc2dac4238        1           24 System.WeakReference
00007ffc2d6eb908        1           24 System.WeakReference`1[[Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions, Microsoft.AspNetCore.Server.Kestrel.Core]]
00007ffc2d6e4120        1           24 System.WeakReference`1[[System.Runtime.Loader.AssemblyLoadContext, System.Private.CoreLib]]
00007ffc2d572b68        1           24 System.WeakReference`1[[Microsoft.Extensions.DependencyInjection.ServiceProvider, Microsoft.Extensions.DependencyInjection]]
00007ffc2d429258        1           24 System.WeakReference`1[[System.IO.FileSystemWatcher, System.IO.FileSystem.Watcher]]
00007ffc2dd15c20        1           32 Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle
00007ffc2d6de4d8        1           32 Internal.Cryptography.Pal.Native.SafeLocalAllocHandle
00007ffc2d68fa00        1           32 Internal.Cryptography.Pal.Native.SafeCertStoreHandle
00007ffc2d3a5cc0        1           32 System.Net.Quic.Implementations.MsQuic.Internal.SafeMsQuicRegistrationHandle
00007ffc2db390c8        1           40 Interop+WinHttp+SafeWinHttpHandle
00007ffc2d69a420        1           40 Internal.Cryptography.Pal.Native.SafeCertContextHandle
00007ffc2d5bea18        1           40 System.Diagnostics.EventLog
00007ffc2dc29a38        1           48 System.Net.Security.SafeFreeCredential_SECURITY
00007ffc2d963f80        2           48 System.WeakReference`1[[System.Text.RegularExpressions.RegexReplacement, System.Text.RegularExpressions]]
00007ffc2d7a3750        2           48 System.WeakReference`1[[Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelConnection, Microsoft.AspNetCore.Server.Kestrel.Core]]
00007ffc2d685e10        1           56 System.Runtime.CompilerServices.ConditionalWeakTable`2+Container[[System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1+ThreadLocalArray[[System.Char, System.Private.CoreLib]][], System.Private.CoreLib],[System.Object, System.Private.CoreLib]]
00007ffc2d44c4d0        1           56 System.Runtime.CompilerServices.ConditionalWeakTable`2+Container[[System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1+ThreadLocalArray[[System.Byte, System.Private.CoreLib]][], System.Private.CoreLib],[System.Object, System.Private.CoreLib]]
00007ffc2d96be68        1           64 CellStore`1[[System.Uri, System.Private.Uri]]
00007ffc2d96b780        1           64 FlagCellStore
00007ffc2d96af48        1           64 CellStore`1[[System.Object, System.Private.CoreLib]]
00007ffc2d96a5b8        1           64 CellStore`1[[OfficeOpenXml.ExcelCoreValue, Magicodes.IE.EPPlus]]
00007ffc2d6ddab8        2           64 Internal.Cryptography.Pal.Native.SafeChainEngineHandle
00007ffc2d69d528        2           64 Internal.Win32.SafeHandles.SafeRegistryHandle
00007ffc2d685bc8        2           64 Microsoft.Win32.SafeHandles.SafeWaitHandle
00007ffc2d685280        3           72 System.Threading.ThreadInt64PersistentCounter+ThreadLocalNodeFinalizationHelper
00007ffc2d5f5f50        3           72 System.Runtime.InteropServices.PosixSignalRegistration
00007ffc2d4299d0        1           72 Microsoft.Win32.SafeHandles.SafeFileHandle
00007ffc2d6e40b8        1           80 System.Runtime.Loader.DefaultAssemblyLoadContext
00007ffc2dac9ed0        2           96 PageIndex
00007ffc2d96d0c8        2           96 ColumnIndex
00007ffc2d464470        3          120 System.Gen2GcCallback
00007ffc2d40a620        1          120 System.IO.FileSystemWatcher
00007ffc2d96bc18        2          128 CellStore`1[[System.Int32, System.Private.CoreLib]]
00007ffc2dac20c8        2          144 System.Reflection.Emit.DynamicResolver
00007ffc2d680f10        3          144 System.Threading.LowLevelLock
00007ffc2d683c48        3          168 System.Threading.ThreadPoolWorkQueueThreadLocals
00007ffc2d681e80        1          176 System.Threading.LowLevelLifoSemaphore
00007ffc2dc25ef0        1          184 System.Collections.Concurrent.CDSCollectionETWBCLProvider
00007ffc2db8e658        1          184 System.Net.NetEventSource
00007ffc2db8c378        1          184 System.Net.NetEventSource
00007ffc2db38f90        1          184 System.Net.NetEventSource
00007ffc2d90c658        1          184 Microsoft.IO.RecyclableMemoryStreamManager+Events
00007ffc2d689b48        1          184 Microsoft.AspNetCore.Certificates.Generation.CertificateManager+CertificateManagerEventSource
00007ffc2d66f9f8        1          184 System.Diagnostics.Tracing.FrameworkEventSource
00007ffc2d66b720        1          184 System.Net.NetEventSource
00007ffc2d44d128        1          184 System.Buffers.ArrayPoolEventSource
00007ffc2d2e2ec8        1          184 System.Diagnostics.Tracing.NativeRuntimeEventSource
00007ffc2d694e10        1          192 System.Threading.Tasks.TplEventSource
00007ffc2d572ab0        1          192 Microsoft.Extensions.DependencyInjection.DependencyInjectionEventSource
00007ffc2d505f00        1          200 Microsoft.Extensions.Logging.EventSource.LoggingEventSource
00007ffc2db8ade8        1          224 System.Net.NameResolutionTelemetry
00007ffc2d428b08        7          224 System.Threading.PreAllocatedOverlapped
00007ffc2d563c78        1          232 System.Diagnostics.DiagnosticSourceEventSource
00007ffc2d61fe88        1          240 Microsoft.AspNetCore.Hosting.HostingEventSource
00007ffc2db6b788        8          256 System.Threading.TimerQueue+AppDomainTimerSafeHandle
00007ffc2d690270        1          280 System.Net.Sockets.SocketsTelemetry
00007ffc2db6bc80        1          296 System.Net.Http.HttpTelemetry
00007ffc2d68b998        1          336 Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.KestrelEventSource
00007ffc2dc21998        1          360 System.Net.Security.NetSecurityTelemetry
00007ffc2d2dae28        1          384 System.Diagnostics.Tracing.RuntimeEventSource
00007ffc2d66ad60       10          480 System.Net.Sockets.SafeSocketHandle
00007ffc2d2e0240       21          504 System.WeakReference`1[[System.Diagnostics.Tracing.EventSource, System.Private.CoreLib]]
00007ffc2d2b0538        9          648 System.Threading.Thread
00007ffc2d77a188        2          704 Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketReceiver
00007ffc2d90cec0        6          960 Microsoft.IO.RecyclableMemoryStream
00007ffc2d5fc658       10         1280 System.Net.Sockets.Socket
00007ffc2d68d898        4         1536 System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs
00007ffc2d2dc778       42         4704 System.Diagnostics.Tracing.EventSource+OverrideEventProvider
00007ffc2daec058      356        14240 System.Drawing.Bitmap
Total 553 objects
baoqger commented 7 months ago

do you have any update on this issue?

cshung commented 7 months ago

do you have any update on this issue?

No, I am not actively working on this issue, is our suggestion above works for you?

You could try !address without the -summary flag to figure out what the individual pieces of commits are. Trying your repro locally, I could find quite a bit of module images and mapped files.

You can also try !eeheap without the -gc option to see what other heaps the CLR internally uses.

Beside that, we have a new !maddress command built by @leculver, feel free to try that one as well.

@tommcdon, can this issue be closed?