Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

namanhams

macrumors regular
Original poster
Jun 3, 2009
153
0
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.

Thanks.
 

nickculbertson

macrumors regular
Nov 19, 2010
226
0
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.
Nick
 

namanhams

macrumors regular
Original poster
Jun 3, 2009
153
0
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.
Nick

Thanks for your reply ! May i know why you think it's better to have thumbnail sized images ?
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
Thanks for your reply ! May i know why you think it's better to have thumbnail sized images ?

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.
 

namanhams

macrumors regular
Original poster
Jun 3, 2009
153
0
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.


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

LinkMx

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

You should avoid creating UIImage objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.

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

seepel

macrumors 6502
Dec 22, 2009
471
1
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.