Checking Memory Leaks with Valgrind


Valgrind is an award-winning instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

The Valgrind distribution currently includes five production-quality tools: a memory error detector, a thread error detector, a cache and branch-prediction profiler, a call-graph generating cache profiler, and a heap profiler. It also includes two experimental tools: a data race detector, and an instant memory leak detector. It runs on the following platforms: X86/Linux, AMD64/Linux, PPC32/Linux, PPC64/Linux.

[ http://valgrind.org/ ]

Using Valgrind is easy picking. Valgrind -v <program>

2008-01-28-054401_1280x800_scrot.png

Note that you should run the real (machine-code) executable here. If your application is started by, for example, a shell or perl script, you’ll need to modify it to invoke Valgrind on the real executables. Running such scripts directly under Valgrind will result in you getting error reports pertaining to /bin/sh, /usr/bin/perl, or whatever interpreter you’re using. This may not be what you want and can be confusing. You can force the issue by giving the flag –trace-children=yes.

Read the official FAQ to get some clue: http://valgrind.org/docs/manual/manual-core.html#manual-core



Subscribe without commenting


Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.