Reputation: 41745
I'm loading 100s 4k-8k png files(768*768 resolution), total less than 1mg.
Although I do convert them to UIImage and resize/combine images occasionaly,
I was surprised to see ipad device die because of memory warning due to the image loadings.
Is converting to UIImage takes up much more memory than actual byte size of the file?
Thank you.
Upvotes: 1
Views: 1816
Reputation: 6592
You might want to consider how you load images if they aren't all for simultaneous display. There are lots of threads about this here and elsewhere, such as this thread.
UIImage imageNamed
will cache the image (and sometimes Apple's caching is slightly buggy, not releasing properly) whilst UIImage imageWithData
won't, so once no longer displayed, the memory will be released. There are advantages and disadvantages to both depending on your circumstances, so try to get a good understanding of the differences.
Upvotes: 0
Reputation: 14160
That's because png's are decompressed into memory, taking more memory. And each decompressed image will take up to 768*768*4 = 2.25 MByte of memory.
Upvotes: 3