21 ms·
Ask HN: profiling memory - what should we use
Trying to profile the memory on our application.
Using Python, have yet to find the winning profiler.
What are you using to test memory leaks?
Any help would be much appreciated.
- cperciva 18y agoWhat are you using to test memory leaks? 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.
- jlouis 18y agoIn 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 http://guppy-pe.sourceforge.net/#Heapy http://guppy-pe.sourceforge.net/#Heapy 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.