T
Thomas Weidenfeller
Phil said:Tools for finding object leaks are light years ahead of the tools to
locate such problems in C/C++ code. It would have been problematic to
have a runtime tool that could find memory leaks in an arbitrary C/C++
binary in the way that OptimizeIt can locate object leaks in a Java
program.
Give Purify a try in your next C/C++ project (esp. if you develop on a
Unix system like Solaris). You will be surprised
FWIR, the way people dealt with such problems was to write
their own wrappers around malloc()/free() or buy commercial packages
that did the same. But you had to deal with things like this at
compile time, and you often had to change the actual source code to
comply with the semantics for the malloc()/free() wrappers. Ugly.
The above mentioned tool instruments the compiled binary program, so it
also covers any third party and operating system libraries linked
(static or dynamic) into the C/C++ program, too. You don't even need the
source code at all. You will be surprised how many strange things are
already going on in the OS libraries. Binary instrumentation is not only
set up to discover memory leaks, but also out of bounds errors, stack
access errors, uninitialized memory reads and a bunch of other things I
don't remember at the moment.
Doneside: Instrumentation takes time and memory. Also the resulting
binary runs slower. The Solaris GUI is poor (maybe this has changed
since I used it the last time). In addition the testing should be best
combined with a code-coverage analysis to ensure only few stones are
left unturned.
/Thomas (just a long-time user)