wrong memory leak warning ?

Hello,

I'm getting a warning about an object that might not have been released in this code:

-(void) test {
    UIView * myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
    UIView * myViewReference = myView;
    [myViewReference release];
}


Is this a bug or should I read again the fundamentals of Objective C ? :)

regards,
Tex

3 comments
Comment actions Permalink

Well technically I guess it's a bug, but I would say more a limitation; I imagine the logic of the leak detection algorithm is quite primitive in terms of it following references through the code.
This one is quite trivial, but things could get a lot more complex very easily. So I guess it errs on the side of caution and simplicity.
Of course the easy way to not see the limitation is to replace [myViewReference release]; with [myView release];

N.

0
Comment actions Permalink

nedski wrote:

Well technically I guess it's a bug, but I would say more a limitation; I imagine the logic of the leak detection algorithm is quite primitive in terms of it following references through the code.
This one is quite trivial, but things could get a lot more complex very easily. So I guess it errs on the side of caution and simplicity.
Of course the easy way to not see the limitation is to replace [myViewReference release]; with [myView release];

N.


ok, I just wanted to be sure.

thanks

0
Comment actions Permalink

Yes, it's a bug. I've created an issue for this: http://youtrack.jetbrains.net/issue/OC-2219

0

Please sign in to leave a comment.