GDI泄漏检测方法:
1、检查是否GetWindowDC(),后是否有 ReleaseDC()
2、CFont *pOldFont=pDC->SelectObject(&m_Font);
后是否有pDC->SelectObject(pOldFont);
3、CBitmap bmp;
bmp.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());
后是否记得bmp.DeleteObject();
内存泄漏 检测方法
1、检查new,VirtualAlloc , HeapAlloc
, malloc
后是否没有释放
2、_CrtMemState s1, s2, s3;
_CrtMemCheckpoint( &s1 );
// memory allocations take place here
_CrtMemCheckpoint( &s2 );
if ( _CrtMemDifference( &s3, &s1, &s2) )
_CrtMemDumpStatistics( &s3 );
CMemoryState msOld;
msOld.Checkpoint();
msOld.DumpAllObjectsSince();
3、_CrtSetBreakAlloc(18);
4、BoundsChecker工具
5、f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\strcore.cpp(141)
若出现上面的输出则用_CrtDumpMemoryLeaks();来调试
f:\sourcesafe fold\mccsclient\mccsclientdlg.cpp(1863) : {63669} normal block at 0x02F21278, 8 bytes long.
Data: < x > E8 CC F1 02 F0 78 F1 02
一般这个问题是由CString引起的,追一下,改为char指针类型即可。