.netmemory-leakswindbgmanagedsos

How to tell if its a managed memory leak or native memory leak?


My .NET process that interops with native dlls is throwing an OutOfMemory Exception. Following is out put of !address -summary and --eeheap-gc coammands. Does this mean if its a managed leak or native leak?

0:000> !address -summary  
 ProcessParametrs 002f10a8 in range 002f0000 003f0000  
 Environment 002f07f0 in range 002f0000 003f0000  
  
-------------------- Usage SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots) Pct(Busy)   Usage  
   17773000 (  384460) : 18.33%    22.25%    : RegionUsageIsVAD  
   168aa000 (  369320) : 17.61%    00.00%    : RegionUsageFree  
   110fe000 (  279544) : 13.33%    16.18%    : RegionUsageImage  
   395fe000 (  940024) : 44.83%    54.41%    : RegionUsageStack  
     396000 (    3672) : 00.18%    00.21%    : RegionUsageTeb  
    7540000 (  120064) : 05.73%    06.95%    : RegionUsageHeap  
          0 (       0) : 00.00%    00.00%    : RegionUsagePageHeap  
       1000 (       4) : 00.00%    00.00%    : RegionUsagePeb  
          0 (       0) : 00.00%    00.00%    : RegionUsageProcessParametrs  
          0 (       0) : 00.00%    00.00%    : RegionUsageEnvironmentBlock  
       Tot: 7fff0000 (2097088 KB) Busy: 69746000 (1727768 KB)  
  
-------------------- Type SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots)  Usage  
   168aa000 (  369320) : 17.61%   : <free>  
   15970000 (  353728) : 16.87%   : MEM_IMAGE  
    47e9000 (   73636) : 03.51%   : MEM_MAPPED  
   4f5ed000 ( 1300404) : 62.01%   : MEM_PRIVATE  
  
-------------------- State SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots)  Usage  
   303e1000 (  790404) : 37.69%   : MEM_COMMIT  
   168aa000 (  369320) : 17.61%   : MEM_FREE  
   39365000 (  937364) : 44.70%   : MEM_RESERVE  
  
Largest free region: Base 0d8b1000 - Size 0010f000 (1084 KB)  
  
0:000> !EEHeap -gc  
Number of GC Heaps: 1  
generation 0 starts at 0x425f776c  
generation 1 starts at 0x425f5a08  
generation 2 starts at 0x01881000  
ephemeral segment allocation context: none  
 segment    begin allocated     size  
01880000 01881000  0281ecf8 0x00f9dcf8(16375032)  
12010000 12011000  12f83a04 0x00f72a04(16198148)  
1e0a0000 1e0a1000  1e734094 0x00693094(6893716)  
41e80000 41e81000  427048d0 0x008838d0(8927440)  
Large object heap starts at 0x02881000  
 segment    begin allocated     size  
02880000 02881000  02a36958 0x001b5958(1792344)  
13010000 13011000  137c0020 0x007af020(8056864)  
Total Size  0x378b9d8(58243544)  
------------------------------  
GC Heap Size  0x378b9d8(58243544)  

Solution

  • 395fe000 ( 940024) : 44.83% 54.41% : RegionUsageStack
    

    Avoid running a thousand threads at the same time.