Removing CAKeyframeAnimation Does Not Free Memory

I add a CAKeyframeAnimation to the ImageView layer to represent the image animation:

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
animation.values = arrayOfImages;
[animation setRemovedOnCompletion:YES];
animation.delegate = self;
[animation setValue:delegate forKey:@"AnimatedImageViewDelegate"];
animation.repeatCount = repeatCount;
animation.fillMode = kCAFillModeForwards;
animation.calculationMode = kCAAnimationDiscrete;
[animation setValue:animationName forKey:@"name"];

When I want to start the animation, I call:

animation.duration = duration;
[self.layer addAnimation:animation forKey:animationName];
[self.layer setContents:[animation.values lastObject]];

When the animation ends, I want to completely remove it and let it go.

[self.layer removeAllAnimations];       
[self.layer removeAnimationForKey:animationName];

By doing this and using Monitor-Activity Monitor, memory is not transferred unless I release the full image.

How can I free this animation memory without destroying UIImageView ???

+5
source share
3 answers

You use the convenience method to create an object. Thus, you will not be able to control when an object is actually released. To have control over this, you will need to select the object and delete it yourself:

Create an instance:

CAKeyframeAnimation *animation = [[CAKeyframeAnimation alloc] init];

:

[animation release];
0

, iOS 5, ARC - !

- . , CA , . , , :

  • , .
  • .
  • -, , .
  • 1-2-3 , . 10 .

.. - - undo - animate - mark. , 0 0, CoreAnimation !

, , :

http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/

0

CAKeyframeAnimation, = . , , [UIImage imagewithname:], . [UIImage imageWithContentsOfFile:] , .

0

All Articles