3

I just upgraded to Mac OS X Mountain Lion and found out that valgrind is still not compatible with Mountain Lion.

I have a 600 line C code that I need to check against memory leaks.

What are possible ways to do it other than valgrind? Can I use Xcode instruments?

darksky
  • 20,411
  • 61
  • 165
  • 254
  • 2
    Install Linux in a VM and run valgrind there. – Kerrek SB Jul 28 '12 at 18:54
  • 3
    Instruments will work fine for C, as long as you have it setup as an Xcode project. – Richard J. Ross III Jul 28 '12 at 18:54
  • Of course... Xcode is yelling at me claiming I have duplicate symbols. When on the command line everything builds perfectly. What do you suggest to do? – darksky Jul 28 '12 at 19:10
  • http://www.sealiesoftware.com/valgrind/ Valgrind is available on OSX, but 600 lines of code... I would go with careful tracking of each malloc call. – Viktor Latypov Jul 28 '12 at 19:19
  • 2
    It is available on OS X for Lion. It is not compatible with Mountain Lion. The code is pretty complicated. I checked for leaks manually but I want to double check to be completely sure. – darksky Jul 28 '12 at 19:26

1 Answers1

5

You could check the clang static analyzer. It's pretty awesome tool for finding bugs in the code.

It's better than valgrind in the fact that it does static analysis rather than running the code — so it can find bugs which you rarely reach. However, it is more likely to trigger false positives as well. And it's not as mature as valgrind.

Michał Górny
  • 18,713
  • 5
  • 53
  • 76