Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory over-release problem when I am animating UIView

I have enabled NSZombie's and I am getting the following message in my console when I am running my application:

 *** -[UIViewAnimationState release]: message sent to deallocated instance 0xf96d7e0

Here is the method that is performing the animation

-(void)loadAvatar:(STObject*)st
{   
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];    

    avatar.alpha = 0;
    avatar.frame = avatarRectSmall;

    avatar.image = [ImageCache getMemoryCachedImageAtUrl:st.avatar_url];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.50];

    avatar.frame = avatarRectNormal;
    [avatar setAlpha:1];
    [UIView commitAnimations];


    [pool release];
    pool = nil;
}

I don't always get a crash, only sometimes. I'm wondering what is getting released?

like image 271
Sheehan Alam Avatar asked Apr 28 '10 01:04

Sheehan Alam


1 Answers

You have an autorelease pool there which prompts me to ask, is this a separate thread? If the answer is yes then you can't do stuff to UIView there. UIKit is not thread safe. You can do other things like calculating positions or updating images which you later put on the screen but any user interface stuff has to happen in the main thread.

Graphics and Drawing section of iPhone Application Programming Guide

like image 94
Adam Eberbach Avatar answered Oct 12 '22 23:10

Adam Eberbach