除了在Mac OS X Mountain Lion和Mavericks上使用valgrind来检测C/ c++应用程序的内存泄漏之外,还有什么替代方法吗?

时间:2022-08-10 16:49:06

I used to use valgrind to detect memory leaks for my C/C++ applications on Mac OS X 10.6 (Snow Leopard) and 10.7 (Lion), but I find it's not supported on recent releases like 10.8 (Mountain Lion) and 10.9 (Mavericks) when I upgraded my OS. Is there something else like valgrind that can be installed on Mac OS X 10.9?

我曾在Mac OS X 10.6 (Snow Leopard)和10.7 (Lion)上使用valgrind检测C/C+应用程序的内存泄漏,但在升级OS时,我发现它不支持最近的版本,比如10.8 (Mountain Lion)和10.9 (Mavericks)。还有什么可以安装在Mac OS X 10.9上的像valgrind的东西吗?

3 个解决方案

#1


12  

On 2013-11-01, the valgrind team announced Valgrind 3.9.0:

在2013-11-01年度,valgrind团队发布了3.9.0:

We are pleased to announce a new release of Valgrind, version 3.9.0, available from http://www.valgrind.org.

我们很高兴地宣布,Valgrind的新版本为3.9.0,可从http://www.valgrind.org获得。

3.9.0 is a feature release with many improvements and the usual collection of bug fixes. This release adds support for MIPS64/Linux, Intel AVX2 instructions and POWER8 instructions. DFP support has been added for S390. Initial support for hardware transactional memory has been added for Intel and POWER platforms. Support for Mac OS X 10.8 (Mountain Lion) has been improved. Accuracy of Memcheck on vectorized code has been improved.

3.9.0是一个特性发布,有很多改进,并且通常会收集bug修复。这个版本增加了对MIPS64/Linux、Intel AVX2指令和POWER8指令的支持。S390增加了DFP支持。英特尔和POWER平台增加了对硬件事务内存的初始支持。对Mac OS X 10.8 (Mountain Lion)的支持已经改进。对矢量化代码的Memcheck的准确性得到了提高。

It remains to be seen whether the improved Mountain Lion support means it works OK for Mavericks. It does mention that the support is only for 64-bit code.

改进后的山狮支持是否对小牛队有效还有待观察。它确实提到,支持仅用于64位代码。

[...time passeth...downloads happen...hopes are raised...configuration is attempted...hopes are dashed...]

[…时间经过…下载发生……希望提出…配置是未遂……希望都破灭了……)

Urgh!

呃! !

...
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking for a supported CPU... ok (x86_64)
checking for a 64-bit only build... no
checking for a 32-bit only build... no
checking for a supported OS... ok (darwin13.0.0)
checking for the kernel version... unsupported (13.0.0)
configure: error: Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)

Mountain Lion is based on Darwin 12.x; Mavericks is based on Darwin 13.x. I'm not sure about the messaging in the error messages, but out of the box, Valgrind 3.9.0 does not compile on OS X Mavericks.

《美洲狮》以达尔文12.x为基础;小牛基于达尔文13.x。我不确定错误消息中的消息,但是从开箱即用的角度来看,Valgrind 3.9.0不能在OS X Mavericks中编译。

#2


11  

Just so you know, you may not have to wait for long to see Valgrind working on Mac 10.9 a.k.a Maverick. As there has been some success according to this bug report.

正如你所知道的,你可能不需要等很长时间才能看到Valgrind在Mac 10.9 a.k上工作。一个特立独行的。根据这个bug报告,已经取得了一些成功。

It is my opinion that there are currently (as of 15th November 2013) no Valgrind alternatives for the Mac. There are some to keep an eye on though, namely Clang which has both AddressSanitizer (works on current macs) and MemorySanitizer (macs not supported yet).

我认为,目前(截至2013年11月15日)还没有Mac的Valgrind替代品。不过,仍有一些替代品需要关注,即同时具有AddressSanitizer(适用于当前的Mac)和MemorySanitizer (Mac尚未支持)的Clang。

There are suggestions to use Xcode's Instruments, but I did not find it useful at all.

有人建议使用Xcode的工具,但我觉得它一点用处也没有。

#3


7  

In addition to the Instruments that @Charlie_Burns mentions above, there's also the static analyzer that can tell you about some of these things just by analyzing your code. In your Xcode project, just select "Analyze" from the "Product" menu. It invokes the clang static analyzer. I think you can use clang directly from the command line if you want, too, though I've not done that.

除了@Charlie_Burns上面提到的工具之外,还有静态分析器,它可以通过分析代码来告诉您其中的一些东西。在Xcode项目中,只需从“Product”菜单中选择“Analyze”。它调用clang静态分析器。我认为您也可以直接从命令行使用clang,尽管我还没有这样做。

On the command line you also have access to the leaks command and the dtracecommand.

在命令行中,您还可以访问leaks命令和dtracecommand。

#1


12  

On 2013-11-01, the valgrind team announced Valgrind 3.9.0:

在2013-11-01年度,valgrind团队发布了3.9.0:

We are pleased to announce a new release of Valgrind, version 3.9.0, available from http://www.valgrind.org.

我们很高兴地宣布,Valgrind的新版本为3.9.0,可从http://www.valgrind.org获得。

3.9.0 is a feature release with many improvements and the usual collection of bug fixes. This release adds support for MIPS64/Linux, Intel AVX2 instructions and POWER8 instructions. DFP support has been added for S390. Initial support for hardware transactional memory has been added for Intel and POWER platforms. Support for Mac OS X 10.8 (Mountain Lion) has been improved. Accuracy of Memcheck on vectorized code has been improved.

3.9.0是一个特性发布,有很多改进,并且通常会收集bug修复。这个版本增加了对MIPS64/Linux、Intel AVX2指令和POWER8指令的支持。S390增加了DFP支持。英特尔和POWER平台增加了对硬件事务内存的初始支持。对Mac OS X 10.8 (Mountain Lion)的支持已经改进。对矢量化代码的Memcheck的准确性得到了提高。

It remains to be seen whether the improved Mountain Lion support means it works OK for Mavericks. It does mention that the support is only for 64-bit code.

改进后的山狮支持是否对小牛队有效还有待观察。它确实提到,支持仅用于64位代码。

[...time passeth...downloads happen...hopes are raised...configuration is attempted...hopes are dashed...]

[…时间经过…下载发生……希望提出…配置是未遂……希望都破灭了……)

Urgh!

呃! !

...
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking for a supported CPU... ok (x86_64)
checking for a 64-bit only build... no
checking for a 32-bit only build... no
checking for a supported OS... ok (darwin13.0.0)
checking for the kernel version... unsupported (13.0.0)
configure: error: Valgrind works on Darwin 10.x and 11.x (Mac OS X 10.6/7)

Mountain Lion is based on Darwin 12.x; Mavericks is based on Darwin 13.x. I'm not sure about the messaging in the error messages, but out of the box, Valgrind 3.9.0 does not compile on OS X Mavericks.

《美洲狮》以达尔文12.x为基础;小牛基于达尔文13.x。我不确定错误消息中的消息,但是从开箱即用的角度来看,Valgrind 3.9.0不能在OS X Mavericks中编译。

#2


11  

Just so you know, you may not have to wait for long to see Valgrind working on Mac 10.9 a.k.a Maverick. As there has been some success according to this bug report.

正如你所知道的,你可能不需要等很长时间才能看到Valgrind在Mac 10.9 a.k上工作。一个特立独行的。根据这个bug报告,已经取得了一些成功。

It is my opinion that there are currently (as of 15th November 2013) no Valgrind alternatives for the Mac. There are some to keep an eye on though, namely Clang which has both AddressSanitizer (works on current macs) and MemorySanitizer (macs not supported yet).

我认为,目前(截至2013年11月15日)还没有Mac的Valgrind替代品。不过,仍有一些替代品需要关注,即同时具有AddressSanitizer(适用于当前的Mac)和MemorySanitizer (Mac尚未支持)的Clang。

There are suggestions to use Xcode's Instruments, but I did not find it useful at all.

有人建议使用Xcode的工具,但我觉得它一点用处也没有。

#3


7  

In addition to the Instruments that @Charlie_Burns mentions above, there's also the static analyzer that can tell you about some of these things just by analyzing your code. In your Xcode project, just select "Analyze" from the "Product" menu. It invokes the clang static analyzer. I think you can use clang directly from the command line if you want, too, though I've not done that.

除了@Charlie_Burns上面提到的工具之外,还有静态分析器,它可以通过分析代码来告诉您其中的一些东西。在Xcode项目中,只需从“Product”菜单中选择“Analyze”。它调用clang静态分析器。我认为您也可以直接从命令行使用clang,尽管我还没有这样做。

On the command line you also have access to the leaks command and the dtracecommand.

在命令行中,您还可以访问leaks命令和dtracecommand。