From: Michael Atherton []
Sent: January 28, 2004 9:08 PM
To: Andrew Rau-Chaplin
Subject: Re: Memory tools

Hi. I used Valgrind ( as my memory tool. I used it with the memcheck option. Using memcheck is memory intensive. If it is a large program you are running you can try using Addrcheck. It is a lighter weight tool. It uses less resources then memcheck but it doesn't find as many problems.

To use memcheck,

valgrind --skin=memcheck ./cubing 1

all the arguments for valgrind start with --

For instance if you want it to print a trace of all your malloc and free's type valgrind --trace-malloc=yes ./cubing 1

A more useful argument to use is:

valgrind --leak-check=yes ./cubing 1

This will tell you how much memory you have allocated in how many calls. It also tells you how many free's you have used. If you compile the code with -g option and then you use valgrind it will tell you what file, function and line number any problems occur on. For instance if you have a memory leak it will tell you exactly where the memory was originally allocated.

Other tools that come with valgrind are Helgrind and cachegrind. I haven't used either of these.

Helgrind can be used to look for data-race conditions in your code when you use the Pthreads library.

cachegrind can be used to see how many cache misses your program has. The documentation says it can tell you what line of your code the misses occur on.

All these tools are open source. They appear to have documentation describing how these programs work. They only work on x86-Linux programs.

This is just a quick overview. I just followed their documentation on the web site and expermented with the different arguments.