在gdb中为linux启用memleak选项 [英] Enable memleak option in gdb for linux

查看:278
本文介绍了在gdb中为linux启用memleak选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



哪个命令可以执行哪个命令我在gdb中设置内存泄漏并检查堆?



我试过了:

 (gdb)check -leaks 

checkpoint:在劣势中找不到fork函数。

(gdb)帮助信息堆

未定义的信息命令:heap。尝试帮助信息。

(gdb)帮助信息泄漏

未定义的信息命令:leaks。尝试帮助信息。


解决方案

Valgrind是人们指出的答案。通常,Valgrind只会在程序执行结束时报告错误。您可以将Valgrind与GDB( vgdb )链接,以便在程序执行过程中转储Valgrind统计信息,并在GDB下运行。



提及一个类似的问题:

倾倒Valgrind报告的丢失内存内容


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

解决方案

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

这篇关于在gdb中为linux启用memleak选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆