I'm not suggesting that this is a good approach or that anyone else should use it, but... I run with ktrace and with MALLOC_OPTIONS=U set in the environment. This logs every single call to malloc(), realloc(), and free(); I then throw the log files at a perl script which matches up allocations with frees and gives me a list of every time memory was allocated without being subsequently freed.
Of course, this is only feasible because I'm working in C; and I'm sure there are better tools available if I could be bothered to learn how to use them.
In a garbage collected language it is way easier than having to trace malloc()/free() calls and then run perl scripts. The sandbox the program is running in can just be changed accordingly, see
for a Python heap profiler. As for C, my weapon of choice is Valgrind. It sandboxes the application and can also do some simple cache profiling etc. It is pretty easy to run as well as there are no need to link any special memory allocator into your program.
I'm not suggesting that this is a good approach or that anyone else should use it, but... I run with ktrace and with MALLOC_OPTIONS=U set in the environment. This logs every single call to malloc(), realloc(), and free(); I then throw the log files at a perl script which matches up allocations with frees and gives me a list of every time memory was allocated without being subsequently freed.
Of course, this is only feasible because I'm working in C; and I'm sure there are better tools available if I could be bothered to learn how to use them.