Apples开发者_StackOverflow社区 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?
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.
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.
精彩评论