Enable memleak option in gdb for linux

21,455

Valgrind is your answer as people have pointed out. Normally, Valgrind will only report errors at the end of your program's execution. You can link Valgrind with GDB (vgdb) to dump Valgrind stats during a program's execution while it's running under GDB.

Refer to a similar question asked:

Dumping contents of lost memory reported by Valgrind

Share:
21,455
user862833
Author by

user862833

Updated on July 09, 2022

Comments

  • user862833
    user862833 almost 2 years

    I am trying to see which process which is causing a memory leak, and dump the heap which is causing it to see what is the issue.

    Which command do I use in gdb to set the memory leak on and check the heap?

    I tried:

    (gdb) check -leaks
    
    checkpoint: can't find fork function in inferior.
    
    (gdb) help info heap
    
    Undefined info command: "heap".  Try "help info".
    
    (gdb) help info leaks 
    
    Undefined info command: "leaks".  Try "help info".
    
  • Brian Vandenberg
    Brian Vandenberg about 10 years
    While I'm fond of valgrind, unfortunately it isn't available on all platforms. The OP asked about gdb, which is available on more platforms than valgrind (e.g., sparc solaris).