Re: Instruments and leaks in a DRM framework
Re: Instruments and leaks in a DRM framework
- Subject: Re: Instruments and leaks in a DRM framework
- From: Wim Lewis <email@hidden>
- Date: Tue, 03 May 2011 23:15:06 -0700
On May 1, 2011, at 3:42 AM, Jose R.P. - Renacentist Software wrote:
> I've run "Instruments" in order to detect leaks in a sample xcodeproj (RTestApp) for the framework I'm creating. There are leaks and the tool never identifies my Framework as the responsible one, but there are at least fifty "Foundation" (substringWithRange:) and "libcrypto" (CRYPTO_malloc) leaks.
>
> Is this result reliable? I mean, I don't want to be fooled by Instruments into believing that I'm not the responsible of the leaks.
Instruments (or malloc_history or any of the similar tools) will tell you where the object was allocated, but that doesn't always tell you who should have freed it. For example, if you have code like this
NSString *blah = [otherString substringWIthRange: ... ];
[blah retain];
...
// never getting around to releasing it
will show the source of the leaked string as -substringWIthRange:, but the bug is in your code.
Most of the time the culprit is visible somewhere in the call stack above the malloc event that Instruments finds; that's why it records the call stack for you. In more complicated situations you may have to trace through multiple retains, releases, autoreleases, and the like to find the unbalanced call.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden