看板 Programming 關於我們 聯絡資訊
※ 引述《wayfarer (wayfarer)》之銘言: : 在每個 *.cpp 的檔案中加入下面這四行,要加在你的 #include <...> 之後, : 要不然會影響到那些include的header files。 : //================================================== : #ifdef _DEBUG : #include <crtdbg.h> : #define new new(_NORMAL_BLOCK ,__FILE__, __LINE__) : #endif : //================================================== : 這樣在 Debug 模式run程式,最後那些沒被delete的 memory block, : VC都會告訴你是在那個檔案的那一行沒被delete。 查了一下, vc2005 還要在程式結束前加上: //======================= #ifdef _DEBUG _CrtDumpMemoryLeaks(); #endif //======================= 這樣就有了: Detected memory leaks! Dumping objects -> c:\documents and settings\administrator\my documents\visual studio 2005\projects\test1\test1\test1.cpp(18) : {92} normal block at 0x003A7A60, 40 bytes long. Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD Object dump complete. 我用VC2003不用 call _CrtDumpMemoryLeaks() 也行。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 222.250.127.47
Uihc:謝謝你熱心的分享~我用的是vs2003..但是沒有 61.31.149.50 08/23 22:07
Uihc:出現像您說的提示訊息..是不是因為我的錯誤 61.31.149.50 08/23 22:08
Uihc:並不是因為沒有釋放記憶體,而是其他原因?.? 61.31.149.50 08/23 22:09