您的位置:首页 > 运维架构

使用pageheap调试程序,监控内存

2016-01-25 16:10 489 查看
from:http://blog.sina.com.cn/s/blog_9d549eab0100zucl.html

(1)将pageheap.exe放到要监控的.exe所在目录下,如E:\project\VehicleDetection\Project\TLOnlineDetection\x64\Debug
(2)以系统管理员身份执行cmd
(3)在cmd中定位到.exe所在目录
(4)执行“pageheap /enable XX.exe ”指令,即将.exe加入到pageheap监控列表中。
(5)执行“pageheap”语句来查看是否将XX.exe加到了pageheap的列表中。
(6)然后“在外部(双击XX.exe)直接运行” 或者 “通过VC调试运行都行” .exe,使用VC调试运行,你将会注意到在Output窗口的加载各种DLL之前,多了几句话:

  Loaded exports for 'C:\WINNT\System32\ntdll.dll'

  Page heap: process 0x57C created heap @ 00130000 (00230000, flags 0x1)

  Loaded 'C:\WINNT\system32\MFC42D.DLL', no matching symbolic information found.

  ..

  Loaded 'C:\WINNT\system32\MSVCP60D.DLL', no matching symbolic information found.

  Page heap: process 0x57C created heap @ 00470000 (00570000, flags 0x1)

  Loaded exports for 'C:\WINNT\system32\imm32.dll'

  这就是Page Heap的监视机制在发挥作用!他告诉你你的堆00470000被创建出来了。
然后程序退出后,Output窗口有这么几句话表明一定有什么错误发生了:

  Page heap: block @ 0015AFF8 is corrupted (reason 10) 

  Page heap: reason: corrupted suffix pattern 

  Page heap: process 0x57C destroyed heap @ 00471000 (00570000)

  The thread 0x8A8 has exited with code 0 (0x0).

  这说明在销毁堆00470000时遇到了麻烦,就是数据块0015AFF8被误用了,原因是误用了下标语法。看,说得多么清楚!也节省了许多翻来覆去查代码的工作!
  (7) 如果有问题,则pageheap会报错。

  (8) 运行结束后,执行“pageheap /disable XX.exe”来终止监控。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: