Hi, I'm currently writing an app that creates a complex hierarchy of CALayers. Everytime I animate one of the layers, I get a memory leak. In order to investigate the issue, I created a simple Cocoa project in which I only added a CustomView and the following code for this view :
@implementation CustomView - (void) awakeFromNib { CALayer *mainLayer = [[CALayer layer] retain]; [self setLayer:mainLayer]; [self setWantsLayer:YES]; // create a dummy sublayer to mainLayer l1 = [CALayer layer]; // l1 is defined as a CALayer * in the header file l1.frame = CGRectMake(0.0, 0.0, 80.0, 30.0); [mainLayer addSublayer:l1]; // create a dummy sublayer to l1 l2 = [CATextLayer layer]; // l2 is defined as a CATextLayer * in the header file l2.frame = CGRectMake(10.0, 10.0, 60.0, 20.0); l2.string = @"test"; [l1 addSublayer:l2]; // trigger a repeating layer animation [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(fromTimer:) userInfo:nil repeats:YES]; } - (void) fromTimer: (NSTimer *) t { if (l1.opacity == 1.0) l1.opacity = 0.2; else l1.opacity = 1.0; } @end When I run the program in MallocDebug, the memory usage goes up every time the timer function is executed. If I change the animation to be on l2 instead of l1, or if I create l2 as a sublayer of mainLayer, the memory usage remains constant. Am I doing something wrong ? Thanks Stephane _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]