Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Qnx IDE: Tip of the Day #14: Quick way to find memory leaks in C/C++programs: (1 Item)
   
Qnx IDE: Tip of the Day #14: 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.

The only thing you really need is the binary with debug information on the host side.
If you cannot run it from Qnx IDE you can run it on target side with special options and attach to it.

To run from IDE:
- If you don't use IDE to build yoru binary create simple makefile project and drop your binary in there 
- Select it, right click and select Run as QNX Application Dialog...
- Select target, Environment, Arguments
- Switch to Tools tab and Add Memory Analysis tooling, Enable switch to this tool's perspective
- When app started, double click on "session" in Sessions view of Memory Analysis perspective,
it would open an graphical editor
- Let your app run, maybe execute a test that makes it leak memory
- Now switch to Settings tab and press get Leaks button
- Switch to Errors tab and you should see Leaks errors there if you have any. Click on error line
to see allocation backtrace. This object has no references and has not being freed.

To run on target:
- Run your app from target terminal as:
rm /tmp/traces.rmat; LD_PRELOAD=librcheck.so MALLOC_CTHREAD=1 MALLOC_TRACE=1 MALLOC_FILE=/tmp/traces.rmat ./your_app
- On the host create Attach configuration instead of regular one (from Profile... menu)
- Enabled Memory Analysis tooling and make sure that it uses same file name in Advanced Settings as MALLOC_FILE var
- When you start it would ask to select a process from the list
- The rest as the same as above

If you need more details please consult User Documentation.
Attachment: Image MemoryLeaks.png 130.51 KB