The Tools tool reports a memory leak for CALayer. I have a custom class, a subclass of UIViewController; in viewDidLoad () I create a view with a CAGradientLayer and insert this view as a subview of the current view, for example:
UIControl *view = [[[UIControl alloc] initWithFrame:CGRectMake(10, 10, 460, 220)] autorelease];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor whiteColor] CGColor], (id)[[UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1.0] CGColor],nil];
gradient.startPoint = CGPointMake(0, 0);
gradient.endPoint = CGPointMake(1, 1);
[view.layer insertSublayer:gradient atIndex:0];
view.layer.masksToBounds = YES;
[view.layer setCornerRadius:5];
[self.view insertSubview:view atIndex:1];
When I run the code in the simulator, everything is fine. However, when I run it on the device (iOS 4.3.3), the Tool tool reports leaks for CALayer. When I exit this code, there are no leaks. What is the problem?
Edit: I found that these are only leaks if I insert a subview into a view that has scrollview (so my gradient-sized subview is inserted between the view and scroll).
source