views:

34

answers:

2

Hi all,

I need to use animation in my iPad application.When I use the animations the memory is increasing and getting exception..When I launch my application the size of the memory is 10 mb, once the animations are started it is increasing the memory size upto double of the launch space (it is 30 mb). I test for the allocations and leaks everything is perfect but still I got this problem. I don't know why it is happening. My animation code is as follows.Please help me.

     [UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
if ([currentView superview])
{

    [UIView  setAnimationTransition:UIViewAnimationTransitionFlipFromRight  forView:mainView cache:YES];
    [currentView removeFromSuperview];
    [mainView addSubview:nextView];

}

[UIView commitAnimations];

Thanks in advance, Sekhar Bethalam.

A: 

I'm not sure if it's the method itself that is increasing the memory usage but likely your view controller that's being loaded in?

Also try adding these lines in your animation block as I think it's encouraged (please correct me if I am wrong) [currentView viewWillAppear:YES]; [currentView viewDidAppear:YES]; [mainView viewWillDisappear:YES]; [mainView viewDidDisappear:YES];

Also I believe setAnimationTransition is now discouraged in IOS4 so maybe try using + (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Chris
A: 

How sure are you that the animation is causing the leak?

What happens when you add/remove subviews without the animation? Is the leak still there?

Where is nextView initialized/released?

What exactly is if ([currentView superview]) meant to check for because I think it'll always return True?

domino