views:

75

answers:

2

My favorite candidate again. I am in the process of identifying memory leaks in my app (a puzzling challenge for a newbe like me).

I am using the xCode leak analyzer, but what puzzles me is how to trace back a memory leak to its variable or value. Is there a pointer to the instances that have reserved a memory address where a leak is identifyed?

How do I best go about it?

+2  A: 

Are you aware of the Clang analyzer? Hit Cmd-Shift-A in Xcode and prepare to be pleasantly surprised. (This should run the Build → Build and Analyze command. It’s something like building the sources, but you get an analyzer log instead of the binary. Hopefully the analyzer will detect at least some of your leaks.)

zoul
not sure whether I will. Just tried, but at what point should I hit it and what would you expect to see? (Am asking this since I am running a mac terminal from server and some keyboard shortcuts arrive properly)
iFloh
Wait. What? What "leak analyzer" are you using, then? The assumption in this answer is that you are using the Xcode application to do your dev work, as implied by your question. If you aren't doing something the standard way, say so clearly in your question.
bbum
hi bbum, if you read the abov you know what I use ... xCode, leak analyser. I just run the mac via vine server, but that doesn't influence the app behaviour ...
iFloh
@ifloh: In the target settings for your project, under "Build Options" you should set the "Run static analyzer" flag. This will run the Clang static analyzer every time you build your code and the analyzer messages will appear as part of your build output.
JeremyP
@Jeremy - thanks for this hint. I was running xCode 3.1.3 that did not support this analysis. I now updatet to 3.2.2 and now use it ...
iFloh
A: 

The XCode leak analyzer tells you where the objects that were leaked were created, if you click the 'extended detail' tab on the right side of the toolbar at the bottom of the window. A call stack showing you which function created the object is shown on the right.

fsmc