title: CoreGraphics drawing causes memory warnings/crash on iOS 7
body: <p>After updating my iPad (mini) to iOS7 I experienced that my drawing app is lagging and crashing after a few strokes.</p>
  
  <p>Now, when I run the app with Instruments/memory allocation tool in xcode 5, I see that the <strong>VM: CG raster data</strong> category is filling up rapidly when drawing on the screen. There seems to be a multitude of <strong>CGDataProviderCreateWithCopyOfData</strong> calls being made, each 3.00Mb in size. After continous drawing the app receives memory warnings, and usually terminates.</p>
  
  <p>The code basically strokes paths into an imagecontext, more or less like this:</p>
  
  <pre><code>UIGraphicsBeginImageContext(self.view.frame.size);
  [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
  CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
  CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
  CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
  CGContextBeginPath(UIGraphicsGetCurrentContext());
  CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
  CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
  CGContextStrokePath(UIGraphicsGetCurrentContext());
  drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  </code></pre>
  
  <p>On iOS7/iPad this is extremely laggy and has memory issues, while on iOS6 this was fairly speedy and had no negative memory footprint.</p>
  
  <p>When I run this code in a non-retina iPhone version the <strong>CGDataProviderCreateWithCopyOfData</strong> calls are 604Kb in size, and only one or two are "active" at the same time. The drawing is fluent and fast with no memory warnings and no slowdown.</p>
  
  <p>What happened from iOS6 to iOS7 regarding CoreGraphics and imagecontexts?</p>
  
  <p>Sorry for any lingo errors or other possible stupid mistakes. Still a noob, doing iOS development in my spare time.</p>