On Aug 10, 2008, at 12:37 PM, Michael Kaye wrote:
I've ben running my app with leaks in Instruments and it is reporting a fair number of leaks.

On analyzing these leaks, they all appear to be related to apple frameworks methods/code and never as a direct result of any objects I've instantiated.

Therefore my question is, is whether this is correct and what you would normally expect to see? Or are the leaks indirectly caused by something I am doing? If the former should I just ignore them and if the latter how do I track down exactly where it is occurring.

While I have seen an occasional report of a leak from the run loop throughout a really long (~20 minutes) analysis session, if you have a fair number of leaks I think its safe to assume they are of your doing.

A couple tips:
- If you are viewing the list of allocations for a particular block, oftentimes you may see a whole lot of framework activity in the history. Remember that the last line is the only one that leaked. - While tracking down a couple hard-to-find leaks last week, I found the "Outline View" with "Invert Call Tree" to be quite helpful. It not only shows the root functions that leaked (eg malloc), but allows you to look and see what all called that and leaked, and so on. That way you can move up past the frameworks to see which of your functions are calling the low-level stuff. - If your program is still running, you can double-click a leaking method/function to pull it up in Xcode for further scrutiny. Of course this only works for what you have source code access to, that is, your own methods. I'm not sure why it only works when running, YMMV on that.

Whilst we are on it, I have a second question and that is whether should I expect any singleton object to "appear" as a memory leak in Instruments. Obviously the point of a singleton is is that it has one instance and any instance variables exist with no dealloc. So does Instruments handle this or just report them as a leak?

To be useful, a reference must be kept to the singleton. As long as this reference is kept, it has not leaked. A leak is when an object/ memory is allocated, but then all references to the object are lost. In this scenario there is no way to release/autorelease/free it anymore, ever, so it has leaked. But when there is still a reference to an object, Leaks will assume you are waiting to release it later.

hope this helps,
-natevw
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to