对于具体的函数,你还可以用CMemoryState来查看是否内存泄漏如:// example for CMemoryState::CMemoryState // Includes all CMemoryState functions CMemoryState msOld, msNew, msDif; msOld.Checkpoint(); CAge* page1 = new CAge( 21 ); CAge* page2 = new CAge( 22 ); msOld.DumpAllObjectsSince(); msNew.Checkpoint(); msDif.Difference( msOld, msNew ); msDif.DumpStatistics();The results from this program are as follows:Dumping objects -> {2} a CObject at $190A {1} a CObject at $18EA Object dump complete. 0 bytes in 0 Free Blocks 8 bytes in 2 Object Blocks 0 bytes in 0 Non-Object Blocks Largest number used: 8 bytes Total allocations: 8 bytes
下载地址:
http://www.vckbase.com/tools/debug/BChecker6.01.zip另外,在VC的输出窗口中(Output)里面有时也会有内存泄漏的信息
// Includes all CMemoryState functions
CMemoryState msOld, msNew, msDif;
msOld.Checkpoint();
CAge* page1 = new CAge( 21 );
CAge* page2 = new CAge( 22 );
msOld.DumpAllObjectsSince();
msNew.Checkpoint();
msDif.Difference( msOld, msNew );
msDif.DumpStatistics();The results from this program are as follows:Dumping objects ->
{2} a CObject at $190A
{1} a CObject at $18EA
Object dump complete.
0 bytes in 0 Free Blocks
8 bytes in 2 Object Blocks
0 bytes in 0 Non-Object Blocks
Largest number used: 8 bytes
Total allocations: 8 bytes
DebugView比较小巧