title: UIGraphicsBeginImageContextWithOptions very masive memory disaster
body: <p>I have this line of code to take screenshot of uiview:</p>
  
  <pre><code>    - (UIImage *)imageWithView:(UIView *)view {
      UIImage *viewImage = nil;
      float height;
      UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
      if(orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight){
          height = view.frame.size.height;
      }else{
          height = 730;
      }
      UIGraphicsBeginImageContextWithOptions(CGSizeMake(view.frame.size.width, height), YES, 0.0);
  
          [view drawViewHierarchyInRect:CGRectMake(0, -60, view.bounds.size.width, height) afterScreenUpdates:YES];
          viewImage = UIGraphicsGetImageFromCurrentImageContext();
  
  
      UIGraphicsEndImageContext();
      return viewImage;
  }
  </code></pre>
  
  <p>... in this uiview is UIWebView.</p>
  
  <p>This <code>- (UIImage *)imageWithView:(UIView *)view</code> method I call in everytime uiwebview finish load. And there's is my problem: When I open some small webpages like google it method takes some kb of memory, but when I open something biger like bbc, cnn, yahoo or stackoverflow, it can take up to 80mb memory usage.</p>
  
  <p>There is snapshoot of instrument when cnn.com was opened.
  <img src="https://i.stack.imgur.com/4QNqz.png" alt="enter image description here">
  After few seconds it realeses, but I don't want that big memory usage, because you might imagine, how useless becomes uiwebview in these seconds.</p>
  
  <p>So, what is your suggestions, how to take screenshoot of uiwebview, without so big memory usage, I don't even need this <code>uiimage</code> in good quality, because I put it in 120*80 <code>uiimageview</code> in one of the screen corners.</p>