views:

72

answers:

2

Hi
Apples documentation recommends to use pngs when loading images. But if you have a large number, isn't it possible to conserve memory by using jpegs instead? Or are they internally converted back to png after load so it makes no difference?

+2  A: 

Glossing over a few details, a loaded image takes the same amount of memory regardless of the source of the image, such as a JPEG or PNG file. Each file type is converted into the internal representation. I don't know which code takes more temporary memory in the process of converting an image from the disc file to the internal representation between the JPEG loading code and the PNG loading code.

JPEG files can save plenty of disc space.

Mr. Berna
A: 

I think the main advantage is that PNGs (especially iPhone PNGs, as generated by pngcrush -iphone on Apple's version of pngcrush) load faster; not that they use less RAM than (say) JPEG.

I suspect you're confusing the term "memory" — it's usually used to mean RAM. Flash usage is more usually referred to as "disk space" or similar. Apple skips the issue entirely by calling total space "Capacity" and free space "Available".

The key to using memory efficiently is to not have any memory leaks (use Leaks to find some; it doesn't catch anywhere near all of them though), and then to free memory in response to a memory warning.

tc.
coming from a web development background, I am accustomed to always thinking of jpegs as 'loading' faster, which they do since they are comprised of fewer bits of data. Will convert my assets to pngs to see if there is an improvement in application launch time.
eco_bach
They may be transferred faster over the network, but they still need to be decompressed (and converted to the native format of the graphics chip, which I think is BGRA). Photos are taken as JPEGs so decompression can't be *that* slow...
tc.