简体   繁体   English

Valgrind喜欢Mac OS 10.7(Lion)上的工具

[英]Valgrind like tool on Mac OS 10.7 (Lion)

I need a tool which helps me to find memory leaks in ac program in a similar way valgrind does. 我需要一个工具,帮助我以类似的方式找到ac程序中的内存泄漏。 It should figures out when a program overwrites memory it should not (eg by miscalculating an array index). 它应该计算出程序何时覆盖它不应该存在的内存(例如,通过错误计算数组索引)。 I learned that there is the leaks utility along with the graphical instruments app. 我了解到泄漏实用程序以及图形仪器应用程序。

However I think it can just find memory allocated with new (or malloc) which was not released and is not accessible anymore. 但是我认为它可以找到分配了新的(或malloc)的内存,这些内存未被释放且不再可访问。 Also I learned that valgrind is supposed to work on older releases (10.5 and 10.6), but I use lion (10.7). 我还了解到valgrind应该适用于旧版本(10.5和10.6),但我使用的是Lion(10.7)。

Valgrind 3.7.0 (released 5 th November 2011) supports Lion. Valgrind 3.7.0(2011年11月5 发布)支持Lion。 http://valgrind.org http://valgrind.org

I would use the XCode developer tool MallocDebug . 我会使用XCode开发人员工具MallocDebug You should have this installed with XCode in your /Developer folder 您应该在/ Developer文件夹中安装XCode

Alternatively, you can run your application in gdb and use the native malloc logging by running 或者,您可以在gdb中运行应用程序,并通过运行使用本机malloc日志记录

% gdb <program name>
(gdb) set env MallocStackLoggingNoCompact 1
(gdb) run

Then, you can use /usr/bin/leaks and /usr/bin/malloc_history to find obvious leaks 然后,您可以使用/usr/bin/leaks/usr/bin/malloc_history来查找明显的泄漏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM