Memory management bugs, in particular incorrect uses of free, are notoriously hard to debug because the symptoms of the problem show up in a place far disconnected from where the bug actually occurred. For instance, an incorrect free can lead to corruption of a completely unrelated object allocated later.

HeapSafe is a C compiler and runtime library that directly check that a program uses free safely, with time and space overheads low enough (normally below 30%) that it can be used all the time. Furthermore, when HeapSafe does detect an invalid free, it can simply leak the object (and log the problem), preventing the program from failing.

HeapSafe is available in the following formats:

Some examples of C programs converted to HeapSafe can be found in heapsafe-examples-1.0.tar.gz.

More information on HeapSafe can be found at http://memory.intel-research.net.