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();
內(nèi)存泄漏 檢測方法
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)
若出現(xiàn)上面的輸出則用_CrtDumpMemoryLeaks();來調(diào)試
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指針類型即可。