.net程序中的高内存使用率

时间:2014-09-28 03:10:57

标签: .net memory garbage-collection clr

它是一个混合代码程序(C#,C ++),运行一两天后,内存使用率非常高(1.5G)
    当我使用windbg倾倒堆时,我无法理解是什么原因造成的     第一:gc堆大小只有338MB,但RegionUsageIsVAD的内存使用量大约为1G(ps:我不会在我的程序中调用虚拟alloc);
     第二:RegionUsageHeap的内存使用量大约是550MB,然后,我检查本机堆,那里有很多大小为零的虚拟块,我不知道550MB内存来自哪里。 />      转储文件分析如下

0:000> !eeheap -gc                        
Number of GC Heaps: 1         
generation 0 starts at 0x7d138454    
generation 1 starts at 0x7d0eb434  
generation 2 starts at 0x00e61000  
ephemeral segment allocation context: none  
 segment     begin allocated  size  
00e60000  00e61000  01e4d5c4  0xfec5c4(16696772)  
073c0000  073c1000  083a3efc  0xfe2efc(16658172)  
............       
51e00000  51e01000  51f82b60  0x181b60(1579872)  
6b970000  6b971000  6bdd3764  0x462764(4597604)  
7d0a0000  7d0a1000  7d32cb00  0x28bb00(2669312)  
Large object heap starts at 0x01e61000  
 segment     begin allocated  size  
01e60000  01e61000  026784d0  0x8174d0(8484048)  
58d70000  58d71000  59080ef8  0x30fef8(3211000)  
Total Size:              Size: 0x142f30c8 (338637000) bytes.      
GC Heap Size:            Size: 0x142f30c8 (338637000) bytes.    

0:000> !address -summary
 TEB 7efdd000 in range 7efdb000 7efde000  
 TEB 7efda000 in range 7efd8000 7efdb000
 ......    
 TEB 7eeda000 in range 7eed8000 7eedb000  
 ProcessParametrs 006613d8 in range 00660000 00760000  
 Environment 006607f0 in range 00660000 00760000  

-------------------- Usage SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots) Pct(Busy)   Usage  
   3fa15000 ( 1042516) : 49.71%    57.71%    : RegionUsageIsVAD  
   11bf1000 (  290756) : 13.86%    00.00%    : RegionUsageFree  
    961e000 (  153720) : 07.33%    08.51%    : RegionUsageImage  
    30fe000 (   50168) : 02.39%    02.78%    : RegionUsageStack  
          0 (       0) : 00.00%    00.00%    : RegionUsageTeb  
   222cd000 (  559924) : 26.70%    31.00%    : 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: 6e3ff000 (1806332 KB)  

-------------------- Type SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots)  Usage  
   11bf1000 (  290756) : 13.86%   : <free>  
    9edc000 (  162672) : 07.76%   : MEM_IMAGE  
    12d5000 (   19284) : 00.92%   : MEM_MAPPED  
   6324e000 ( 1624376) : 77.46%   : MEM_PRIVATE  

-------------------- State SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots)  Usage  
   60c4b000 ( 1585452) : 75.60%   : MEM_COMMIT  
   11bf1000 (  290756) : 13.86%   : MEM_FREE  
    d7b4000 (  220880) : 10.53%   : MEM_RESERVE  

Largest free region: Base 64d78000 - Size 02008000 (32800 KB)  

0:000> !heap -s  
LFH Key                   : 0x5733fdc1  
Termination on corruption : DISABLED  
  Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast   
                    (k)     (k)    (k)     (k) length      blocks cont. heap   
Virtual block: 08f80000 - 08f80000 (size 00000000)  
Virtual block: 08700000 - 08700000 (size 00000000)  
Virtual block: 0f480000 - 0f480000 (size 00000000)  
00660000 00000002    8192   6984   8192    156   224     4    3      0   LFH  
008a0000 00001002    1088    300   1088     17     5     2    0      0   LFH  
009f0000 00041002     256      4    256      2     1     1    0      0        
00490000 00001002    1088    300   1088     14     5     2    0      0   LFH  
00820000 00001002    1088    300   1088     17     5     2    0      0   LFH  
00280000 00041002     256     16    256      4     1     1    0      0        
00630000 00001002    1088    484   1088      6    14     2    0      0   LFH  
007c0000 00041002    1280    284   1280      1     7     2    0      0   LFH  
00930000 00041002    1280    388   1280      5    48     2    0      0   LFH  
03ab0000 00001002     256     20    256      3     1     1    0      0        
Virtual block: 173c0000 - 173c0000 (size 00000000)  
Virtual block: 17650000 - 17650000 (size 00000000)  
Virtual block: 17860000 - 17860000 (size 00000000)  
...............                                        
Virtual block: 48f00000 - 48f00000 (size 00000000)  
071b0000 00001002  120672 109376 120672    499   201    12  370      0   LFH  
08d30000 00001002   64000  13140  64000  11062   143    46    0      0   LFH  
    External fragmentation  84 % (143 free blocks)  
0fde0000 00001002     256      4    256      1     2     1    0      0        

0 个答案:

没有答案