JuliaLang/julia — pull request #9068 by eschnett (2014-11-19 18:46:03+00:00)
Title: New debug flag MEMNOFREE that disables all calls to free

I'm still debugging my segfault in Julia #8551 . In the course of this, I theorized that memory may be freed and then reused by other objects, causing the segfault. To investigate, I added a build option MEMNOFREE that never frees memory. This applies both to memory freed by garbage collection, as well as memory freed explicitly e.g. by strings, arrays, or other buffers.

This patch wraps plain `malloc`, `realloc`, and `free` via macros, and then redefines these macros to never free memory. (In particular, `realloc` becomes `malloc` and `memcpy`.)

I think this facility is useful for debugging in general, and propose to make it official.