Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AlmostThere

macrumors 6502a
Original poster
As straight to the point as I can be, trying to move over more and more to OS X from Linux, I could do with a quick pointer (ho, ho) to get started with the Apple tools.

Allocate, fill and leak some memory:
Code:
#include <iostream>
#include <algorithm>
int main (int argc, char * const argv[]) 
{
    char *block = new char[100];   
    std::fill(block, block+100, 'z');  
    block[0]     = 'a';                    
    return 0;                               
}

Build then Debug -> Launch with Performance Tool -> MallocDebug
results in a minute or two of spinning rainbow wheel followed the dialogue:

Read Data
Unable to read malloc information from /Path/To/Project/Debug/executable

Building from the command line with -lMallocDebug and loading the programme manually gives the same result and loads of multiple definition warnings.

Surely there is something trivial I am missing :confused:

Are there any other tools worth checking out? Under Linux I have been using valgrind, pretty much since it was released, which frankly has been the bees knees.

Reference MallocDebug at Apple
 

iSee

macrumors 68040
Oct 25, 2004
3,539
272
I ran into this same problem once. I left it alone (I don't write code with leaks anyway :rolleyes: ) but I did find a potential solution.

Look here: http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/ManagingMemory.pdf

at around page 29, in the "Running Under libMallocDebug" section. It seems to describe your situation and what to do about it.

I never actually tried this though, so I don't know if this is really the solution. Anyway, if you don't get a more concrete suggestion, you could give it a try...

good luck...
 

iSee

macrumors 68040
Oct 25, 2004
3,539
272
Sorry that last idea wasn't helpful.

One more thing, though: MallocDebug works by watching a running app. The example app you show executes, finishes and terminates almost immediately. MallocDebug may not be able to attach to it before it finished what it's doing and quits. If you are looking for the type of leak checker that logs what's happening and can give you a report after execution is complete, I don't think MallocDebug is it anyway. I didn't see any logging functions anyway.
 

AlmostThere

macrumors 6502a
Original poster
Yeah, I am rather under than impression. I just kind of feel there should be a good OS X tool that fits the bill. I come back to look at this issue every 18 months or so ... but never seem to be able to track down definitive answers, or more importantly worked examples. So I stuck about the most simple thing I could think of and wondering how to show the error on OS X, rather assuming MallocDebug would be the tool to use.

It has just cropped up again now partly because repeated allocation (that made development much quicker) has now turned into major a bottle neck and also after chatting with another Linux using friend about using Macs / Unix etc. and the tools available, differences and such like.

Anyway, thanks for the input. Will go over the PDF in greater detail sometime soon.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.