Re: NSMutableDictionary Leak
Re: NSMutableDictionary Leak
- Subject: Re: NSMutableDictionary Leak
- From: "Michael Ash" <email@hidden>
- Date: Fri, 28 Nov 2008 22:30:00 -0500
On Fri, Nov 28, 2008 at 7:04 PM, dct <email@hidden> wrote:
> I've started using Instruments/Leaks on a project that has been building and
> running as expected. It has identified a goodly number of CFDictionary leaks
> (a Malloc leak followed by an Autorelease leak) associated with lines that,
> in one typical case, reads:
>
> [tmp setObject:[NSDictionary dictionaryWithDictionary:tmp2]
> forKey:@"Data"];
>
> The MutableDictionary object "tmp" is instantiated at the beginning of this
> particular method by:
>
> NSMutableDictionary *tmp = [[NSMutableDictionary dictionaryWithCapacity:4]
> autorelease];
>
> Do I need to autorelease a la:
>
> [tmp setObject:[[NSDictionary dictionaryWithDictionary:tmp2] autorelease]
> forKey:@"Data"];
>
> or is this a non-problem given that the reported Malloc leak is followed by
> an Autorelease leak?
"An autorelease leak" is not a phrase which makes much sense. I'm
guessing that you're using the ObjectAlloc instrument, either instead
of the Leaks instrument or along with it, and you're misinterpreting
what it says. The ObjectAlloc instrument can be configured to track
every ObjC memory management event, including allocations,
destructions, retains, releases, and autoreleases. It will point out
where each one happens to any object in your app. This does *not*
indicate an error, however. If you're using this instrument and it
says "Autorelease" happened on such-and-such a line, that doesn't mean
there's a problem there. It only means that this event happened on
that line. It could be perfectly legitimate. The purpose of the
tracking is so that you can look at the entire history, and discover
places where the reference counting isn't balanced.
Mike
_______________________________________________
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