Memory Trace Lib Doc

Package:

      This package includes memtrace.h, heaptrace.h, memtrace_com.h and memtrace.lib. To use this package in win32 system to trace HeapAlloc, including <windows.h> before "memtrace.h". To use this package without tracing HeapAlloc, you can use it to trace whatever apps conforms to ANSI C. This package will make your life easier to locate the memory leaks fast. It's also a useful tool to analyze your app's memory usage and find out which code consumes much memory.

Functionality:

Usage:

Sample code:

  1. Tracing HeapAlloc/malloc/new for single thread console app:
    #define TRACE_MALLOC     1
    #define TRACE_NEW            1
    #define TRACE_HEAP           1
    #include "memtrace.h"

    int main()
    {
        HEAP_MEASURE_START()
        your code ...
        WRITE_MEM_LOG
    }
     

  2. Tracing Stack for single thread console app:
    #define TRACE_STACK     1
    #include "memtrace.h"

    int main()
    {
        STACK_MEASURE_START(0)
        your code ...
        STACK_MEASURE_STOP(stack_depth, 0)
        printf("Total Stack Depth: %d", stack_depth);
    }

     

Sample Logs:

*********************
Peek Ram Used: 216343
Peek Ram Distributions:
272 bytes(0.001257 percent) in D:\build\multimedia\src\v8dme\Network\client\dstruct\vcelpool.cpp line 724.
1284 bytes(0.005935 percent) in ..\common\baseclient.h line 64.
800 bytes(0.003698 percent) in ..\common\basesession.h line 72.
592 bytes(0.002736 percent) in ..\wince\asyncresult.h line 179.
20 bytes(0.000092 percent) in ..\include\wmsstring.h line 1055.
520 bytes(0.002404 percent) in D:\build\multimedia\src\v8dme\Network\client\wince\workqueue.h line 294.
168 bytes(0.000777 percent) in D:\build\multimedia\src\v8dme\Network\client\wince\asyncresult.h line 179.
1380 bytes(0.006379 percent) in ..\common\basechannel.h line 65.
171691 bytes(0.793606 percent) in D:\build\multimedia\src\v8dme\Network\client\common\netbuffer.h line 59.
32 bytes(0.000148 percent) in D:\build\multimedia\src\v8dme\Network\client\wince\socketimp.cpp line 779.
1334 bytes(0.006166 percent) in ..\common\netbuffer.h line 59.
6608 bytes(0.030544 percent) in D:\build\multimedia\src\v8dme\Network\client\common\netbuffer.h line 616.
80 bytes(0.000370 percent) in D:\build\multimedia\src\v8dme\Network\client\wince\socketimp.cpp line 665.
15611 bytes(0.072159 percent) in D:\build\multimedia\src\v8dme\Network\client\wince\socketimp.cpp line 678.
60 bytes(0.000277 percent) in D:\build\multimedia\src\v8dme\Network\client\common\netbuffer.cpp line 64.
1024 bytes(0.004733 percent) in D:\build\multimedia\src\v8dme\Network\client\common\incrementalalloc.h line 120.
328 bytes(0.001516 percent) in ..\common\netbuffer.h line 616.
6251 bytes(0.028894 percent) in ..\common\incrementalalloc.h line 120.
3160 bytes(0.014606 percent) in ..\common\ipresentationdescription.h line 133.
1824 bytes(0.008431 percent) in D:\build\multimedia\src\v8dme\Network\client\netstream\netstream.cpp line 1506.

Memory Statistics:
Allocated Total Memory: 2936922 bytes.
Allocated Free Memory: 2900437 bytes.
HeapAlloc Memory: 2936922 bytes.
Malloc Memory: 0 bytes.
New Memory: 0 bytes.
Maximum Ram Used: 221266 bytes.
Detailed Heap Allocated.

292 bytes in d:\build\multimedia\src\v8dme\network\client\dstruct\vcelpool.cpp 722 line. Remain 292 bytes.
2444 bytes in d:\build\multimedia\src\v8dme\network\client\common\baseclient.h 64 line. Remain 2444 bytes.
1320 bytes in d:\build\multimedia\src\v8dme\network\client\common\basesession.h 72 line. Remain 1320 bytes.
64572 bytes in d:\build\multimedia\src\v8dme\network\client\wince\asyncresult.h 179 line. Remain 816 bytes.
13437 bytes in d:\build\multimedia\src\v8dme\network\client\include\wmsstring.h 1055 line. Remain 20 bytes.
520 bytes in d:\build\multimedia\src\v8dme\network\client\wince\workqueue.h 294 line. Remain 520 bytes.
1384 bytes in d:\build\multimedia\src\v8dme\network\client\common\basechannel.h 65 line. Remain 1384 bytes.
11464 bytes in d:\build\multimedia\src\v8dme\network\client\common\inetrequest.h 201 line. Remain 1344 bytes.
1069484 bytes in d:\build\multimedia\src\v8dme\network\client\common\netbuffer.h 59 line. Remain 10720 bytes.
9952 bytes in D:\build\multimedia\src\v8dme\NETWORK\CLIENT\WINCE\socketimp.cpp 779 line. Remain 96 bytes.
1365784 bytes in d:\build\multimedia\src\v8dme\network\client\common\netbuffer.h 616 line. Remain 3980 bytes.
2024 bytes in D:\build\multimedia\src\v8dme\NETWORK\CLIENT\WINCE\socketimp.cpp 1879 line. Remain 78 bytes.
6832 bytes in d:\build\multimedia\src\v8dme\network\client\wince\workqueue.cpp 206 line. Remain 0 bytes.
1904 bytes in D:\build\multimedia\src\v8dme\NETWORK\CLIENT\WINCE\socketimp.cpp 665 line. Remain 0 bytes.
351469 bytes in D:\build\multimedia\src\v8dme\NETWORK\CLIENT\WINCE\socketimp.cpp 678 line. Remain 0 bytes.
60 bytes in d:\build\multimedia\src\v8dme\network\client\common\netbuffer.cpp 64 line. Remain 60 bytes.
28332 bytes in d:\build\multimedia\src\v8dme\network\client\common\incrementalalloc.h 120 line. Remain 8299 bytes.
512 bytes in d:\build\multimedia\src\v8dme\network\client\common\inetrequest.h 83 line. Remain 0 bytes.
3160 bytes in d:\build\multimedia\src\v8dme\network\client\common\ipresentationdescription.h 133 line. Remain 3160 bytes.
1952 bytes in D:\build\multimedia\src\v8dme\Network\client\netstream\netstream.cpp 1508 line. Remain 1952 bytes.
24 bytes in d:\build\multimedia\src\v8dme\network\client\wince\asyncresult.h 356 line. Remain 0 bytes.

Detailed New Allocated.


Detailed Malloc Allocated.

 


last edit on 08/15/2002