http://www.nifty.com/download/special/
特に、隠れた名作では?と思える作品を掘り起こしてみました。
http://d.hatena.ne.jp/shinichiro_h/20070806#1186328951
Windows+VisualCだと,_CrtDumpMemoryLeaksを使った検出で
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
int main(int argc, char**argv)
{
int *p=(int*)malloc(sizeof(int));
*p=0x12345678;
_CrtDumpMemoryLeaks();
}
なコードから
[4948] Detected memory leaks!
[4948] Dumping objects ->
[4948] .\test.cpp(6) :
[4948] {68}
[4948] normal block at 0x003A3100, 4 bytes long.
[4948] Data: <xV4 > 78 56 34 12
[4948] Object dump complete.
な出力を得る事ができますが,最近のVisualStudioだと,「出力」ウィンドウにこの情報がでない.
_CrtDumpMemoryLeaksは,中でOutputDebusStringを使っていますが,これがそもそも動かない.
DebugViewを使えば見えますが,これも「デバッグ開始」じゃだめで「デバッグなしで開始」じゃないとうまく行かない.
VCはバージョンがあがるたびに,色々な知識をリセットされて憂鬱になります.