It is currently Wed Nov 22, 2017 9:07 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 3 posts ] 
Author Message
 Post subject: Visual Leak Detector - A Memory Leak lib for FREE
PostPosted: Wed Sep 17, 2008 9:13 am 

Joined: Sat Jun 23, 2007 7:56 pm
Posts: 145
Hi guys,
Found this great program which works with Visual Studio. It give a detailed report of memory leaks in your program. The default report is given in the Output window, you can also generate report files.

Helped me find over 84 memory leaks last night, enjoy!

http://dmoulding.googlepages.com/vld


Offline
 Profile  
 
 Post subject: Visual Leak Detector - leaks for free
PostPosted: Wed Sep 17, 2008 1:23 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
It seems the thing works all right. I'm very impressed.

This valuable midnight tool goes with source files and is written fairly good, not to say more. :)
It would be a pity if the VLD-project is given up.

A quick glance at the source shows that VLD intercepts all major memory management functions:
    // Win32 heap APIs.
    "kernel32.dll", "GetProcAddress",     0x0, _GetProcAddress, // Not heap related, but can be used to obtain pointers to heap functions.
    "kernel32.dll", "HeapAlloc",          0x0, _RtlAllocateHeap,
    "kernel32.dll", "HeapCreate",         0x0, _HeapCreate,
    "kernel32.dll", "HeapDestroy",        0x0, _HeapDestroy,
    "kernel32.dll", "HeapFree",           0x0, _RtlFreeHeap,
    "kernel32.dll", "HeapReAlloc",        0x0, _RtlReAllocateHeap,

    // MFC new operators (exported by ordinal).
    "mfc42d.dll",   (LPCSTR)714,          0x0, _mfc42d__scalar_new_dbg,
    "mfc42d.dll",   (LPCSTR)711,          0x0, _mfc42d_scalar_new,
    // XXX MFC 7.x DLL new operators still need to be added to this
    //   table, but I don't know their ordinals.
    "mfc80d.dll",   (LPCSTR)895,          0x0, _mfc80d__scalar_new_dbg,
    "mfc80d.dll",   (LPCSTR)269,          0x0, _mfc80d__vector_new_dbg,
    "mfc80d.dll",   (LPCSTR)893,          0x0, _mfc80d_scalar_new,
    "mfc80d.dll",   (LPCSTR)267,          0x0, _mfc80d_vector_new,

    // CRT new operators and heap APIs.
    "msvcr80d.dll", "_calloc_dbg",        0x0, _crt80d__calloc_dbg,
    "msvcr80d.dll", "_malloc_dbg",        0x0, _crt80d__malloc_dbg,
    "msvcr80d.dll", "_realloc_dbg",       0x0, _crt80d__realloc_dbg,
    "msvcr80d.dll", "??2@YAPAXIHPBDH@Z",  0x0, _crt80d__scalar_new_dbg,
    "msvcr80d.dll", "??_U@YAPAXIHPBDH@Z", 0x0, _crt80d__vector_new_dbg,
    "msvcr80d.dll", "calloc",             0x0, _crt80d_calloc,
    "msvcr80d.dll", "malloc",             0x0, _crt80d_malloc,
    "msvcr80d.dll", "realloc",            0x0, _crt80d_realloc,
    "msvcr80d.dll", "??2@YAPAXI@Z",       0x0, _crt80d_scalar_new,
    "msvcr80d.dll", "??_U@YAPAXI@Z",      0x0, _crt80d_vector_new,
    "msvcrtd.dll",  "_calloc_dbg",        0x0, _crtd__calloc_dbg,
    "msvcrtd.dll",  "_malloc_dbg",        0x0, _crtd__malloc_dbg,
    "msvcrtd.dll",  "??2@YAPAXIHPBDH@Z",  0x0, _crtd__scalar_new_dbg,
    "msvcrtd.dll",  "_realloc_dbg",       0x0, _crtd__realloc_dbg,
    "msvcrtd.dll",  "calloc",             0x0, _crtd_calloc,
    "msvcrtd.dll",  "malloc",             0x0, _crtd_malloc,
    "msvcrtd.dll",  "realloc",            0x0, _crtd_realloc,
    "msvcrtd.dll",  "??2@YAPAXI@Z",       0x0, _crtd_scalar_new,

    // NT APIs.
    "ntdll.dll",    "RtlAllocateHeap",    0x0, _RtlAllocateHeap,
    "ntdll.dll",    "RtlFreeHeap",        0x0, _RtlFreeHeap,
    "ntdll.dll",    "RtlReAllocateHeap",  0x0, _RtlReAllocateHeap,

    // COM heap APIs.
    "ole32.dll",    "CoGetMalloc",        0x0, _CoGetMalloc,
    "ole32.dll",    "CoTaskMemAlloc",     0x0, _CoTaskMemAlloc,
    "ole32.dll",    "CoTaskMemRealloc",   0x0, _CoTaskMemRealloc


Offline
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 1:51 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Though, not everything is so smooth. :(
VLD seems cannot catch the next error:
void foo() {
    char * p = new char[0x10];
    delete p; // must be vector form: delete [] p;
}

It does not discriminate scalar-delete against vector-delete. (???) I mean it does not check the matching of new/delete types.
That’s odd.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron