4 Replies Latest reply: Aug 17, 2012 5:41 AM by etresoft
MarionMck Level 1 Level 1 (0 points)

I seem to be missing something when resizing images...

My app has a table view using custom cells with multiple labels and images.  The custom cell initWithFrame allocs the labels and UIImageViews, adds them as subviews and then releases.  The custom cell layout function sets the frame for each of the UIImageViews, not big as there are four images covering only half the width of the cell.  My cellForRowAtIndexPath checks for any existing image (within each image view), releases it if it is there and assigns the appropriate new one into the image view.  My actual image files are large, as they are designed for full screen display on another view, so effectively I'm mimicking a thumbnail type display. I thought the fact that I'd restricted the frame on each UIImageView would ensure that only a small amount of memory would be used for each one.  Yet when the app first shows the table view, 6 rows with a total of 11 images, I get a memory warning from the iPad.

Example photo album style apps I've seen seem to do something similar, they don't use a separate file with a small version of the image.  Any suggestions on what I am doing wrong which is gobbling up memory?

Any assistance much appreciated!

  • 1. Re: memory management and images
    etresoft Level 7 Level 7 (24,270 points)

    The memory consumed by a file is not based on the display size of the file. It is not even based on the size of the file on disk. It is based on the physical dimensions of the file. Even a small JPEG file can turn out to be massive in memory. Find out how big your images should be on the screen with a retina display and create smaller versions of them for your thumbnails. That is your only option.

  • 2. Re: memory management and images
    MarionMck Level 1 Level 1 (0 points)

    Thanks etresoft, but I still think I'm missing something fundamental.  I can take hundreds of photographs on my iPad, each about 1MB.  They will be happily displayed as thumbnail-type images in the Photos app, 5 to a row.  I don't see a second small image file if I browse the iPad.   My image files are around 0.5MB, so surely that means I should be able to do something similar.

  • 3. Re: memory management and images
    MarionMck Level 1 Level 1 (0 points)

    Hhmm, I think I'm beginning to get it, looking at the thumbail example under 'creating an image from an image source'.  Do the ALAssets effectively have a hidden thumbnail which is accessed?

  • 4. Re: memory management and images
    etresoft Level 7 Level 7 (24,270 points)

    That is the size on disk. It means nothing. Look at the dimensions of the image. Multiply the height times the width times 3. That is how much RAM the image will need.