packages icon
This is version 2.2 of mpr, a memory allocation profiler for C/C++ programs.

mpr finds malloc/realloc memory leaks and memory allocation statistics by
using a simple, brute force strategy: log all malloc/free calls to a file and
post-process this log file when the program terminates.

mpr keeps track of the entire call chain leading up to a malloc/free call. This
is superior to conventional methods that keep track of only the immediate
caller using __FILE__ and __LINE__ pre-processor tricks.

As of version 2.0, you no longer need to re-link your application in order to
use mpr.  If your program is dynamically linked, using mpr can be as simple as
typing 'mpr program ...'  (see mpr.html for details).

--

To give you an idea of what mpr can do, here are some sample outputs:

(1) memory allocations grouped by call chains:
    (col2=number of allocs, col3=amount allocated, col4=percent)

main(tst.c,52)                                     55         1760       2.35%
foo(bar.c,14):bar(bar.c,28):main(tst.c,59)         200        2000       2.67%
main(tst.c,47)                                     200        3200       4.27%
foo(bar.c,19):bar(bar.c,28):main(tst.c,59)         200        4000       5.34%
foo(tst.c,34):main(tst.c,58)                       200        12800      17.08%
foo(baz.c,21):baz(baz.c,29):main(tst.c,60)         200        51200      68.30%

(2) memory leaks grouped by call chains:
    (col2=number of allocs leaked, col3=amount leaked, col4=percent)

main(tst.c,47)                                     52         832        2.36%
foo(bar.c,14):bar(bar.c,28):main(tst.c,59)         88         880        2.50%
main(tst.c,52)                                     31         992        2.82%
foo(bar.c,19):bar(bar.c,28):main(tst.c,59)         103        2060       5.85%
foo(tst.c,34):main(tst.c,58)                       108        6912       19.62%
foo(baz.c,21):baz(baz.c,29):main(tst.c,60)         92         23552      66.86%

(3) memory allocations grouped by size:
    (col1=size, col2=number of allocs, col3=amount allocated col4=percent)

32              55              1760            2.35%
10              200             2000            2.67%
16              200             3200            4.27%
20              200             4000            5.34%
64              200             12800           17.08%
256             200             51200           68.30%

(4) memory leaks grouped by size:
    (col1=size, col2=number of allocs leaked, col3=amount leaked, col4=percent)

16              52              832             2.36%
10              88              880             2.50%
32              31              992             2.82%
20              103             2060            5.85%
64              108             6912            19.62%
256             92              23552           66.86%

--

The following tools are supplied with mpr-2.2:
	mpr      - run a program, after setting LD_PRELOAD/MPRFI so that
	           mpr can intercept and log calls to malloc/free
        mprmap   - map program counters in an mpr log to function names and
	           file/line coordinates
        mprchain - group allocations/leaks by call chains
        mprsize  - group allocations/leaks by size
        mprleak  - show memory leaks
        mprhisto - show memory allocation histogram

The currently supported targets are:
        x86-linux

mpr requires GNU GDB in addition to some standard Unix utilities (awk,
sed, nm, sort, cut).

See file LICENSE for terms and conditions under which you may use mpr.
See file INSTALL for instructions on how to build and install mpr.
See directory doc/ for documentation.

mpr was designed to be simple and easy to use - please keep it that way.

Please send all bug reports and suggestions to

    taj.khattra@pobox.com (Taj Khattra)