You asked this just the other day over here, and I gave you this answer:
Although it's no longer being actively developed, for C and ObjC code
(all I've used it for), I haven't found anything better than MSS:
Memory Supervision System.
It's extremely straightforward and easy to setup; has been very
accurate in my experience and I've used it to great effect to weed out
any memory leaks in my applications.
To give you an idea of how easy it is to use: I compiled it into a
static library, link it to my program's debug targets and put the
include (import for ObjC) for the singular header into a common shared
header that all the rest of my program uses, so it tracks memory
across the entire program without even needed to think about it.
MSS will do exactly what you're asking for; it'll give you a ton of extra (extremely-useful) information as well, but the top of the report includes these lines:
MSG: Listing info about allocated blocks at end of program:
INFO: 107 blocks currently allocated
INFO: 11720 bytes of memory currently used.
INFO: 2384479 bytes maximum memory used.
In just those lines, it tells you how many blocks of memory leaked, exactly how much memory leaked and the maximum memory footprint your program used.
How to use MSS:
First build the library using the makefile; just use make lib
as we don't need the test programs. If you're not using gcc, you'll need to change the default compiler in the makefile. If you're using gcc and want both 64-bit and 32-bit versions, add either -m64
or -m32
to line 53 CFLAGS=...
and then just run make
on the file.
You should now have a static library of MSS you can link into your program. The only header you need to include in your program along with the library is mss.h
. To actually use MSS, you need to #define MSS
and #include <mss.h>
into every file you wish to have it track. If you want the entire program tracked, define MSS in the arguments to the compiler and include into a universal header that every source file includes.
That is literally it; there's config files you can add to your program directory if you wish to change the verbosity of its logs and other features, but to just get it working, that is all you need to do. By the way, MSS includes a full read me in its doc folder that describes all this in much more detail.