title: iOS CALayer memory leak only on device
body: <p>The Instruments tool reports memory leak for CALayer.  I have a custom class, a subclass of UIViewController; in the viewDidLoad() I instantiate a view with CAGradientLayer and insert this view as a subview of current view, e.g.:</p>
  
  <pre><code>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];
  </code></pre>
  
  <p>When I run the code in simulator, all is fine.  However when I run it on device (iOS 4.3.3), the Instruments tool reports leaks for CALayer.  When I coment out this code, there are no leaks.
  What is the issue here?</p>
  
  <p>Edit: I found out it only leaks if I insert the subview into a view which has a scrollview (so my subview with the gradient calayer is inserted between the view and scrollview).</p>