【发布时间】:2015-11-20 20:36:16
【问题描述】:
注意:
1. 我尝试传递标志--vgdb=yes,但在这种情况下,进程根本没有运行。
2. 我不赞成检测我的代码。
问题:
我正在尝试在永远运行的自定义操作系统(基于 linux)用户空间进程上运行 valgrind。在这种情况下,我如何获得内存泄漏的 Valgrind 统计信息,即该过程永远运行。
在当前状态下,我使用 Valgrind 启动了该过程并查看了以下日志:
==6561== Memcheck, a memory error detector
==6561== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==6561== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==6561== Command: xyz_server
==6561== Parent PID: 3056
. . . .
==6561==
==6561== Thread 12:
==6561== Syscall param timer_create(evp) points to uninitialised byte(s)
==6561== at 0x84949BD: timer_create (in /lib64/librt-2.12.so)
==6561== by 0x56D518E: api_1 (in . . .) // removed proprietary lib name
==6561== by 0x74DDDD2: api_2 (in . . .) // removed proprietary lib name
==6561== by 0x827A9BB: start_thread (pthread_create.c:301)
==6561== Address 0x1fb37a50 is on thread 12's stack
==6561==
这里没有统计数据。例如,如果我在 ls 上使用相同的 args 运行 valgrind:
$ valgrind --leak-check=full ls -l
==12584== Memcheck, a memory error detector
==12584== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==12584== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==12584== Command: ls -l
==12584==
. . .
==12584== HEAP SUMMARY:
==12584== in use at exit: 18,424 bytes in 10 blocks
==12584== total heap usage: 71 allocs, 61 frees, 63,312 bytes allocated
. . .
==12584== LEAK SUMMARY:
==12584== definitely lost: 0 bytes in 0 blocks
==12584== indirectly lost: 0 bytes in 0 blocks
==12584== possibly lost: 18,424 bytes in 10 blocks
==12584== still reachable: 0 bytes in 0 blocks
==12584== suppressed: 0 bytes in 0 blocks
==12584==
==12584== For counts of detected and suppressed errors, rerun with: -v
==12584== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 2 from 2
. . .
如何获得我的程序的类似统计数据?我的进程永远不会退出。
【问题讨论】:
-
@cad,没有回答我的问题。
-
@ks1322:vgdb 在我的情况下似乎不起作用。其他答案谈论的是检测代码,而不是支持。
标签: linux memory-leaks valgrind