本机内存泄漏-如何查找分配源的调用堆栈 [英] native memory leak - how to find callstack of allocation source

查看:98
本文介绍了本机内存泄漏-如何查找分配源的调用堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于!address -summary命令的以下输出,我认为我发生了本机内存泄漏.为了确定发生这些分配的位置的调用堆栈,我在 http://www.codeproject.com/KB/cpp/MemoryLeak.aspx

Based on following output of !address -summary command, I think I have got a native memory leak. In order to deterine the callstack on where these allocations are happening, I am following article at http://www.codeproject.com/KB/cpp/MemoryLeak.aspx

0:000> !address -summary  
 TEB 7efdd000 in range 7efdb000 7efde000  
 TEB 7efda000 in range 7efd8000 7efdb000  
 TEB 7efd7000 in range 7efd5000 7efd8000  
 TEB 7efaf000 in range 7efad000 7efb0000  
 TEB 7efac000 in range 7efaa000 7efad000  
 ProcessParametrs 00441b78 in range 00440000 00540000  
 Environment 004407f0 in range 00440000 00540000  

-------------------- Usage SUMMARY --------------------------  
    TotSize (      KB)   Pct(Tots) Pct(Busy)   Usage  
    551a000 (   87144) : 04.16%    14.59%    : RegionUsageIsVAD  
   5b8d3000 ( 1499980) : 71.53%    00.00%    : RegionUsageFree  
    2cc3000 (   45836) : 02.19%    07.68%    : RegionUsageImage  
     4ff000 (    5116) : 00.24%    00.86%    : RegionUsageStack  
          0 (       0) : 00.00%    00.00%    : RegionUsageTeb  
   1c040000 (  459008) : 21.89%    76.87%    : 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: 2471d000 (597108 KB)  


0:000> !heap -s  
LFH Key                   : 0x7fdcf95f  
Termination on corruption : DISABLED  
  Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast   
                    (k)     (k)    (k)     (k) length      blocks cont. heap   
-----------------------------------------------------------------------------  
00440000 00000002  453568 436656 453568     62    54    32    0      0   LFH    
006b0000 00001002      64     16     64      4     2     1    0      0        
002b0000 00041002     256      4    256      2     1     1    0      0        
00620000 00001002      64     16     64      5     2     1    0      0        
00250000 00001002      64     16     64      4     2     1    0      0        
007d0000 00041002     256      4    256      0     1     1    0      0        
005c0000 00001002    1088    388   1088      7    17     2    0      0   LFH  
02070000 00041002     256      4    256      1     1     1    0      0        
02270000 00041002     256    144    256      0     1     1    0      0   LFH  
04e10000 00001002    3136   1764   3136    384    36     3    0      0   LFH  
    External fragmentation  21 % (36 free blocks)  
-----------------------------------------------------------------------------  

但是,当我运行!heap -p –a命令时,我没有得到任何调用堆栈,只有以下内容.有什么想法如何获得分配源的调用栈吗?

But when I run !heap -p –a command, I don’t get any callstack, just the following. Any ideas how to get callstack of allocations source?

0:000> !heap -p -a 0218e008  
    address 0218e008 found in  
    _HEAP @ 4e10000  
      HEAP_ENTRY Size Prev Flags    UserPtr UserSize - state  
        0218e000 001c 0000  [00]   0218e008    000d4 - (busy)  

推荐答案

如果没有从!heap -p -a
获得调用堆栈 原因可能是您没有正确使用gflags
请记住使用正确的名称,包括.exe
尝试整体启动它,然后转到图像"标签,可能会更容易
尝试使用页面堆,这也会提供调用堆栈

If you don't get a call stack from !heap -p -a
The reason can be that you have not used gflags correctly
Remeber to use correct name including .exe
Try to start it inteactivly and go to the image tab, might be easier
Try with page heap, that also gives call stack

这篇关于本机内存泄漏-如何查找分配源的调用堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆