Implement libgmalloc
This is a simple implementation of libgmalloc as found on OS X.
Use it like this:
$ DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib DYLD_FORCE_FLAT_NAMESPACE=1 ./executable
You may also want to try using MALLOC_PROTECT_BEFORE and/or MALLOC_FILL_SPACE.
Unfortunately, using libgmalloc skyrockets the memory and address space usage,
so it's nearly impossible to use it with complex executables.