Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any alternatives to valgrind on Mac OS X Mountain Lion and Mavericks to detect memory leaks for C/C++ applications? [closed]

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?

like image 344
hago Avatar asked Nov 01 '13 02:11

hago


People also ask

Does macOS have valgrind?

Valgrind for macOS. This repository contains a version of Valgrind including a few patches to improve support for the macOS platform. It is maintained by Louis Brunner.

Does valgrind work on M1 Mac?

Valgrind does not seem to work on M1 Macs. Issue #5 · LouisBrunner/homebrew-valgrind · GitHub.

What does the valgrind program do?

Valgrind (/ˈvælɡrɪnd/) is a programming tool for memory debugging, memory leak detection, and profiling. Valgrind was originally designed to be a free memory debugging tool for Linux on x86, but has since evolved to become a generic framework for creating dynamic analysis tools such as checkers and profilers.


2 Answers

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

We are pleased to announce a new release of Valgrind, version 3.9.0, available from 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.

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.

[...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.

like image 72
Jonathan Leffler Avatar answered Sep 17 '22 14:09

Jonathan Leffler


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.

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).

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

like image 32
chutsu Avatar answered Sep 19 '22 14:09

chutsu