memleax
attachs a running process, hooks memory allocate/free APIs, records all memory blocks, and reports the blocks which live longer than 5 seconds (you can change this time by -e option) in real time.
So it is very convenient to use. There is no need to recompile the program or restart the target process. You run memleax
to monitor the target process, wait the real-time memory leak report, and kill it (e.g. by Ctrl-C) to stop monitoring.
NOTE: Since memleax
does not run along with the whole life of target process, it assumes the long-live memory blocks are memory leak. Downside is you have to set the expire threshold by -e option according to your scenarios; while the upside is the memory allocation for process initialization is skipped, besides of the convenience.