Using gdb to find memory leaks in HP Unix
Sunday, March 1st, 2009The following gdb commands are used to setup memory leak detection in C++ programs:
set heap-check leaks on
set heap-check free on
set heap-check bounds on
set heap-check scramble on
To show the leak the following command is used:
(gdb) info leaks
To view a particular leak from a list of leaks detected use the following:
(gdb) info leakĀ <leak number> ( leak number is the relevant number from the leak)
It is very important that program be linked with librt.sl shared library to use heap profiling.
The following example is using xscAppAdapter as a C++ program to demonstrate memory leak detection.