



Parameters
-
lBreakAlloc
Allocation order number, for which to set the breakpoint.
Return Value
Returns the previous object allocation order number that had a breakpoint set.
具体用法
1. debug应用程序MyApp
2.在退出app的时候通常会看到output window中提示这样的信息:
Detected memory leaks! Dumping objects -> {523983} normal block at 0x082D54D8, 16 bytes long. Data: <Folder_Root > 46 6F 6C 64 65 72 5F 52 6F 6F 74 00 00 00 00 00 f:/sp/vctools/vc7libs/ship/atlmfc/src/mfc/plex.cpp(29) : {459891} normal block at 0x0852E340, 164 bytes long. Data: < #S D t$S > E0 23 53 08 44 04 00 00 01 00 00 00 74 24 53 08 |
把它们copy 保存起来。 其中位于大括号中的数字表明这是本程序第几次分配内存,但是到程序结束却没有释放掉这一块内存,后面还有信息说明这一次内存泄漏共有到少内存。
3. 再次启动做相同的动作后退出app,查看output window类似的内存泄漏提示信息, 找出和上一次相同的数字,以523983为例。然后在文件添加以下代码:




4.重新debug app,程序就会自动的停在内存泄漏发生的地方,此时就可以借助Call Stack window定位到真正引起内存泄漏的地方