Valgrind的massif工具不会剖析我的应用程序 [英] Valgrind's massif tool will not profile my application

查看:481
本文介绍了Valgrind的massif工具不会剖析我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自CentOS存储库的标准gcc 4.4软件包在64位CentOS 5.8上开发静态链接的64位C ++应用程序.它似乎正在使用比我预期更多的内存,因此我尝试使用massif来分析内存使用情况.我已使用调试信息进行编译,然后运行

I am developing a statically-linked 64-bit C++ application on 64-bit CentOS 5.8 using the standard gcc 4.4 packages from the CentOS repositories. It appears to be using more memory than I expected, so I tried using massif to profile the memory usage. I have compiled with debug information and then run

valgrind --tool = massif ./MyProg

valgrind --tool=massif ./MyProg

从MyProg所在的目录.除了下面的massif.out.XXXX示例外,它永远不会产生任何结果.

from the directory where MyProg resides. It never produces any results other than the following massif.out.XXXX example.

desc: (none)
cmd: ./MyProg
time_unit: i
#-----------
snapshot=0
#-----------
time=0
mem_heap_B=0
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty

请注意,这就是文件的全部内容,我的程序可以运行很多分钟.

Note that that is the entire contents of the file and my program can run for many minutes.

我尝试了各种方法来使valgrind和massif无效.我什至尝试使用MyProg的绝对路径,以防万一.我尝试下载valgrind的最新稳定版本(3.8.1)并编译并运行该版本(因为CentOS使用3.5.0),结果相同.作为健全性检查,我跑了

I have tried various options to valgrind and massif to no avail. I even tried using the absolute path to MyProg, just in case. I've tried downloading the most recent stable version of valgrind (3.8.1) and compiling and running that (since CentOS is using 3.5.0) with the same result. As a sanity check I ran

valgrind --tool = massif ls -l <​​/p>

valgrind --tool=massif ls -l

并按预期生成了多个快照,并且内存使用量不为零.

and it produced multiple snapshots with non-zero memory usage as expected.

我尝试过使用可能想到的每种关键字组合进行在线搜索,但没有发现任何类似的问题.

I've tried searching online using every combination of keywords I could think of but did not find any similar problems.

作为旁注,如果有用的信息,我可以使用valgrind的默认memcheck工具成功地对应用程序进行概要分析.

As a side note, I can successfully profile the application using valgrind's default memcheck tool, in case that is useful information.

有人知道为什么massif无法分析我的应用程序吗?

Does anyone know why massif would fail to profile my application?

推荐答案

如果应用程序是静态链接的,则无法使用valgrind对其进行分析. Valgrind的工作原理是为程序提供它自己的分配函数版本,该函数可以通过覆盖动态查找来实现.

If the application is statically linked, it cannot be analyzed using valgrind. Valgrind works by providing it's own version of the allocation functions to your program, which it accomplishes by overriding the dynamic lookup.

如果您可以动态链接标准库(libc和libstdc ++),那么它应该可以执行您要查找的内存分析.

If you can dynamically link with the standard libraries (libc and libstdc++), then it should probably be able to perform the memory analysis you're looking for.

Valgrind常见问题解答:

第二,如果您的程序是静态链接的,则大多数Valgrind工具也无法正常工作,因为它们无法用自己的版本替换某些功能,例如malloc.

Second, if your program is statically linked, most Valgrind tools won't work as well, because they won't be able to replace certain functions, such as malloc, with their own versions.

这篇关于Valgrind的massif工具不会剖析我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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