Show Table of Contents
2.16. Valgrind
Valgrind 提供大量的检测及分析工具以帮助提高应用程序的性能。这些工具能检测内存和与线程相关的错误,同样也能检测堆、栈和数组的超限运行,使用户能够轻松地定位和修改应用程序代码错误。它也可以配置缓存、堆和分支预测来确定能增加应用程序速度并最小化内存使用率的因素。
Valgrind 通过在合成的 CPU 上运行应用程序来进行分析,并在执行时对现有的应用程序代码进行测试。之后显示的评论会清楚地标识出每个参与应用程序执行的进程至用户指定文件、文件描述符或网络 socket。要注意的是执行测试代码会花上正常执行情况下四至五十倍的时间。
Valgrind 可以按原样应用于应用程序,不需要进行重新编制。但由于 Valgrind 使用调试信息来定位编码中的问题,若应用程序和支持库没有启用调试信息编制,红帽建议进行程序编制以便能包含该信息。
Valgrind 也与 GNU 项目调试器 (gdb)一起使用来提高调试效率。
Valgrind 及其附属工具有助于内存分析。关于使用 Valgrind 分析系统内存,详情请见 第 4.2.2 节 “用 Valgrind 分析应用程序的内存使用量”。
关于 Valgrind,详情请见红帽企业版 Linux 7 开发者指南,可从 http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/ 中获取。
关于使用 Valgrind,详情请见手册页:
$ man valgrind
当 valgrind 数据包安装后,附带文档可以在
/usr/share/doc/valgrind-version 中找到。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.