title: Large (UI)Image Memory Management
body: <p>I'm working on an iPad-only iOS app that essentially downloads large, high quality images (JPEG) from Dropbox and shows the selected image in a UIScrollView and UIImageView, allowing the user to zoom and pan the image.</p>
  
  <p>The app is mainly used for showing the images to potential clients who are interested in buying them as framed prints. The way it works is that the image is first shown, zoomed and panned to show the potential client if they like the image. If they do like it, they can decide if they want to crop a specific area (while keeping to specific aspect ratios/sizes) and the final image (cropped or not) is then sent as an email attachment to production.</p>
  
  <p>The problem I've been facing for a while now, is that even though the app will only be running on new iPads (ie. more memory etc.), <strong>I'm unable to find a method of handling the images so that the app doesn't get a memory warning and then crash</strong>.</p>
  
  <p>Most of the images are sized 4256x2832, which brings the memory usage to at least 40MB per image. While I'm only displaying one image at a time, image cropping (which is the main memory/crash problem at the moment) is creating a new cropped image, which in turn momentarily bumps the apps total RAM usage to about 120MB, causing a crash.</p>
  
  <p><strong>So in short</strong>: I'm looking for a way to manage very large images, have the ability to crop them and after cropping still have enough memory to send them as email attachments.</p>
  
  <p>I've been thinking about implementing a singleton image manager, which all the views would use and it would only contain one big image at a time, but I'm not sure if that's the right way to go, or even if it'd help in any way.</p>