Memory leak/error tool for OS X?

Joined
Aug 3, 2004
Messages
39
Reaction score
0
Points
6
I use Rational Purify all the time at work, but it's only available for SunOS, Irix, redhat, and windows. Can anyone recommend a similar tool for OS X? I have seen a code called OmniObjectMeter, but it looks like it can only handle full-fledged applications which have been linked through Project Builder, not simple command line linked applications (e.g. an a.out which links in nothing and prints "hello world" to the terminal).

Also, I have a long standing problem with debug-compiled (-g) objects which essentially makes gdb inconvenient and useless. Whenever I enter gdb, I always have to provide it the directories where the original source code objects are located. This is not trivial when I am linking in several dozen libraries or building different variants of codes under different source trees. Is there a way for gcc to encode the full paths into the objects to make gdb less cumbersome?

Thanks.
 
Joined
Mar 9, 2004
Messages
2,860
Reaction score
21
Points
38
Location
Miami FL
Your Mac's Specs
G4 1Ghz OS X 10.4.7
Memory leaks issues are one of the very best strong points of OS X: there are none that I have ever heard of and it's why the force quit app can safely stop a locked or looping app without affecting the rest of the system
 
OP
M
Joined
Aug 3, 2004
Messages
39
Reaction score
0
Points
6
I'm not so concerned about system level memory leaks as opposed to application level leaks. Imagine calling a C++ method that does nothing but allocate space, use it locally, but never delete it. Even though the system is safe from being harmed by this, the application may eventually kill itself when space runs out.


void Blort()
{
int *a = new int [10000];
a[0] = 5;
}

int main()
{
while (1)
Blort();
return 0;
}
 
Joined
Mar 9, 2004
Messages
2,860
Reaction score
21
Points
38
Location
Miami FL
Your Mac's Specs
G4 1Ghz OS X 10.4.7
miggles, application level leaks. Dude There's the difference!
 
D

dr_springfield

Guest
leaks

http://developer.apple.com/documentation/Darwin/Reference/ManPages/html/leaks.1.html

But I've never used it. I typically use the memory management tools that come with Xcode. In one of the menus (not on a mac right now so I cant say exactly)... Debug probably, you'll see "Run with..." and there are several apps in there. The one that has the icon that looks like a melting icecube is my favorite. Wish I could tell you the name, but my brain is goo.
 
OP
M
Joined
Aug 3, 2004
Messages
39
Reaction score
0
Points
6
Thanks for the pointer dr_springfield. Unfortunately, that doesn't seem able to work with plain vanilla g++ compiled code either:

% leaks ./a.out
leaks cannot find a process you have access to which has a name like './a.out'


Also, is there anything to trap memory errors such as UMRs (uninitialized memory reads) or FMRs (freed memory reads) as they happen? I'm interested in something that doesn't require the target application to link in the Carbon lib because I am working with codes that compile on multiple architectures (mainly different flavors of Unix). Thanks.
 
D

dr_springfield

Guest
miggles said:
Thanks for the pointer dr_springfield. Unfortunately, that doesn't seem able to work with plain vanilla g++ compiled code either:

% leaks ./a.out
leaks cannot find a process you have access to which has a name like './a.out'
Just tested this out.
Leaks only works on running executables. It's irritating, but you can just make your code wait for input when you want to check for memory leaks, and then run the command then.
Also check out the "heap" and "malloc_history" commands.
miggles said:
Also, is there anything to trap memory errors such as UMRs (uninitialized memory reads) or FMRs (freed memory reads) as they happen? I'm interested in something that doesn't require the target application to link in the Carbon lib because I am working with codes that compile on multiple architectures (mainly different flavors of Unix). Thanks.

gdb should handle this, shouldn't it? I'm not particularly good with gdb... I just sort of use it to do exactly what I have to do and don't know the entire massive extent of it's capabilities, but it seems like you could get that sort of info from gdb.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top