如何在守护程序上进行内存检查? [英] How to do memory check on a daemon program?

查看:111
本文介绍了如何在守护程序上进行内存检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个C ++应用程序,该应用程序可以一直运行直到手动终止. 它监视其他重要应用程序.结果,我的Daemon应用程序不应关闭. 记住这一点,我想看看我的应用程序中是否有任何内存泄漏. 我使用了valgrind,但是由于该应用程序永远运行,因此valgrind不会退出.如果我进行控制-C,则不会从valgrind日志文件中获取完整的信息.

I have written a C++ application, that runs forever until terminated manually. It monitors other important applications. As a result my Daemon application should not go down. Keeping that in mind, I want to see if there are any memory leaks in my application. I used valgrind but since this application keeps running forever the valgrind does not exit. if I do a control - C then I don't get complete info from the valgrind logfile.

有没有一种工具可以执行Valgrind的工作?

Is there a tool that can do what Valgrind does?

推荐答案

我相信您可以将gdb连接到正在运行的valgrind进程,并指示它明确运行泄漏检查.

I believe you can connect gdb to a running valgrind process, and instruct it to run a leak check explicitly.

我还没有尝试过,只是在文档.

I haven't tried this, just seen it in the docs.

如果链接断开:

$ valgrind --tool=memcheck --vgdb=yes --vgdb-error=0 ./prog

(错误参数是gdbserver变为活动状态之前的错误数:零表示它立即开始运行).

(the error parameter is the number of errors before the gdbserver becomes active: zero means it starts running right away).

然后在程序上启动gdb并连接到远程目标

Then start gdb on your program and connect to the remote target

$ gdb ./prog
(gdb) target remote | vgdb

并触发支票

(gdb) monitor leak_check full reachable any

有关详细信息,请参阅您的文档或链接的文档.

See your docs or the linked ones for full details.

这篇关于如何在守护程序上进行内存检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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