Enable memleak option in gdb for linux

2019-06-24 20:59发布

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".

2条回答
时光不老,我们不散
2楼-- · 2019-06-24 21:22

info leaks and info heap are commands that are available in gdb only on HP-UX (HP-UX gdb is a customized version of Open Source GNU debugger gdb and is called on The HP Wildebeest Debugger (WDB) - http://www.hp.com/go/wdb ). On Linux you need to use valgrind.

查看更多
We Are One
3楼-- · 2019-06-24 21:27

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

查看更多
登录 后发表回答