I am using several CALayer in my application with great UIImage as content. Unfortunately, when I do not need a layer and an image, the memory is not freed.
The code I use to create the layer is:
UIImage *im = [UIImage imageNamed:@"image_1.jpg"];
CALayer * l = [CALayer layer];
[l setBounds:CGRectMake(0, 0, 1024, 768)];
[l setPosition:CGPointMake(512, 384)];
[l setAnchorPoint:CGPointMake(0.5, 0.5)];
[l setHidden:NO];
[l setContents:(id) im.CGImage];
[self.layer addSublayer:l];
[self.tmpArr addObject:l];
The code I use to release the layer and its contents:
CALayer * l = [self.tmpArr objectAtIndex:i];
[l removeFromSuperlayer];
[l setHidden:YES];
[l setContents:nil];
[self.tmpArr removeAllObjects];
when I use the tool memory profiler, I see that the real memory increases when the layer is created, but does not decrease when it is freed. I cannot use release since I am using ARC. what am i doing wrong here?
Thank.
source
share