Personal tools
You are here: Home cmgui Wiki Cmgui using valgrind
Views
FrontPage >>

Cmgui using valgrind

last edited 11 months ago by andre

Brief Overview

Cmgui is tested with valgrind to check for memory leaks. This page is here to help anybody wanting to check their own work for memory leaks using valgrind on GNU/Linux.

Setup

Valgrind reports a lot of errors that won't directly relate to Cmgui. To help remove this chaf we ewill create a suppression file to help minimise the noise. To create our suppression list we will need.

  1. A build of Cmgui (preferably with debugging symbols)
  2. valgrind
  3. this extract suppressions bash script

Now we will run valgrind using our build of Cmgui using this command:

valgrind --leak-check=yes --gen-suppressions=all --track-origins=yes --quiet <cmgui-binary-name> 2> valgrind.output

where your <cmgui-binary-name> might be 'cmgui-wx'. When the Cmgui window appears quit the application.

quit_cmgui_progress.png

Now extract the suppressions using the bash script (sorry to all those non-bash users).:

./extract_valgrind_suppressions.script -a valgrind.output

Notes:

  • Some help and further options can be found with ./extract_valgrind_suppressions.script -h
  • The '-a' option appends to our suppression list

For reasons unknown to me we need to iterate this process a couple of times. Valgrind it seems picks up some different leaks on different runs.

To repeat we use this command that uses the latest suppression file.:

valgrind --leak-check=yes --gen-suppressions=all --track-origins=yes --suppressions=cmgui.supp --quiet <cmgui-binary-name> 2> valgrind.output

then extract any new suppressions with:

./extract_valgrind_suppressions.script -a valgrind.output

We need to repeat this process until valgrind reports no more memory leaks.

Using Valgrind

Now we have created a suppression file that removes some of the noise from our system we can run Cmgui and test your own code for memory leaks using valgrind like so:

valgrind --leak-check=yes --track-origins=yes --suppressions=cmgui.supp --quiet <cmgui-binary-name> 2> valgrind.output

Seem familiar, well we have already been using valgrind but now you are on your own. Any new leaks detected could be memory leaks due to your changes and will need fixing if they are.

Contributing to this site

Please add to the wiki any relevant information that you think might be useful to other users of this website. For example, you might like to contribute your experiences, questions and answers.

You are encouraged to contribute to this site regardless of your level of experience. Contributions are welcomed from new and regular visitors.

If you ask a question and receive an answer from a developer you should record it in the wiki. This information is extremely useful and can help other users overcome the same problem.

See how to add and edit pages for more information.