Re: static analyzers says I'm leaking, I _think_ I'm not
Re: static analyzers says I'm leaking, I _think_ I'm not
- Subject: Re: static analyzers says I'm leaking, I _think_ I'm not
- From: Charles Srstka <email@hidden>
- Date: Thu, 07 May 2015 13:16:10 -0500
On May 7, 2015, at 6:44 AM, Daniel Höpfl <email@hidden> wrote:
>
> I'd change the code as follows:
>
> // init
> self.cycler = [[[GridCycler alloc] initWithGrid: self] autorelease];
>
> // alternative init, if you want to bypass the autorelease pool:
>
> GridCycler *cycler = [[GridCycler alloc] initWithGrid: self];
> self.cycler = cycler;
> [cycler release];
> // Don't use [self.cycler release], one day you might change the property to copy.
>
>
> // dealloc:
> // nothing.
The dealloc is wrong here; that still has to release the property, either by setting it to nil or by releasing the ivar (not through a property access). With MRC, properties aren’t automatically released on dealloc.
So, in dealloc, either:
[_cycler release];
or:
self.cycler = nil;
Charles
_______________________________________________
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