views:

489

answers:

3

Hello, I fear that some of my code is causing memory leaks, and I'm not sure about how to check it. Is there a tool or something for MacOS X?

Thank you

+4  A: 

Yes - there's an application called MallocDebug which is installed as part of the Xcode package.

You can find it in the /Developer/Applications/Performance Tools folder.

Nick Dowell
+2  A: 

Apple has a good description of how to use MallocDebug on OS X on their developer pages.

Pieter
+1  A: 

Of course UNIX provides a quick and dirty way of detecting memory leaks... top.

Launch your app and watch the system memory allocated to your process over time. If it continually grows when it shouldn't then there is likely a memory leak. At which point you break out Valgrind or use MallocDebug, etc.

Of course if you use smart pointers and/or RAII, then you shouldn't have memory leaks in your code, right? ;)))

ceretullis
Yes, in fact I'm trying to check if my implementation of smart pointers is working correctly :)
tunnuz
Any reason for not using boost::scoped_ptr or boost::shared_ptr ??
ceretullis