Quick way to find memory leaks in C/C++programs#

If your application is leaking memory the best way to find out where it is leaking is to use Memory Analysis tool.

For first iteration you only need

Finding leaks by attaching to application#

This would describe how to create launch configuration to find memory leaks in a binary that was not build in IDE and cannot be launched from IDE.

Now go back to target terminal:

Modify you launch script to include extra environment variables (and remove trace file, if exists): rm /tmp/traces.rmat; LD_PRELOAD=librcheck.so MALLOC_CTHREAD=1 MALLOC_TRACE=1 MALLOC_FILE=/tmp/traces.rmat ./your_app <arg>

and run it, switch back to IDE


Finding leaks by running from IDE#

What to do if backtrace is not there or has not enough data#

If you see a leak but it does not point to source code or there is no backtrace:

What to do if you don't have TCP/IP connection#

If you need more details please consult User Documentation.