small UIImageView display large UIImage : memroy usage ?

Discussion in 'iOS Programming' started by namanhams, Mar 25, 2011.

  1. namanhams macrumors regular

    Jun 3, 2009
    Let's say i have a very large UIImage with size 5000 * 5000. I display it in a UIImageView with size 50 * 50, and let the UIImage fits into the UIImageView.

    What can we say about memory usage in this case ?

    I need to display a lot of UIImage, could be small size of large size, and i want to avoid app crash due to low memory.

  2. nickculbertson macrumors regular


    Nov 19, 2010
    Nashville, TN
    I'd say put thumbnail sized images in thumbnail ImageViews. I'm not sure what your app's intended functionality is but having a few Jumbo png files probably wont crash your app. However smaller images load faster and look less pixelated in smaller spaces.
  3. namanhams thread starter macrumors regular

    Jun 3, 2009
    Thanks for your reply ! May i know why you think it's better to have thumbnail sized images ?
  4. admanimal macrumors 68040

    Apr 22, 2005
    Because there will be huge memory and processing savings by working with 50 x 50 (or some similar sized) images as much as possible and only using the 5000x5000 images when absolutely necessary (i.e. probably never).

    Just one 5000 x 5000 color image will use 75MB of RAM when it is used in its uncompressed form by an app, which is already way more RAM than I would reasonably expect would be available for the entire app.

    Really the only appropriate way to display a 5000 x 5000 image at full size on an iPhone is to tile it and use a scroll view. This involves only loading the pieces of the image are visible at a given time and will significantly improve memory usage and performance. If you're going to shrink it so much that the whole thing can fit on the phone at once, you should probably just have smaller images available.
  5. namanhams thread starter macrumors regular

    Jun 3, 2009

    Hi. Thanks for your reply ! But the reason of my question is that i want to know the memory usage of the UIImageView.
  6. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Try it and see? Instruments lets you track memory usage.
  7. LinkMx macrumors member

    Sep 20, 2007
    You wouldn`t even be able to load the image to the imageView, your app would crash:

    In the iPad and iPhone 4 the max resolution for an image to display is 2048x2048.
  8. seepel macrumors 6502


    Dec 22, 2009
    It sounds like you want to be using a CATileLayer anyway. It will allow you to adjust which image to use for the UIImageView's scale factor.

Share This Page