I’m creating a UIView similar to Apple’s Scrolling example and I have a question regarding UIImage and caching; I don’t know if I fully understand the practical implications of the Apple Documentation.
The docs say:
Discussion
This method loads the image data into memory and marks it as purgeable. If the data is purged and needs to be reloaded, the image object loads that data again from the specified path.
In practice, what does this mean?
I’m reading it like this: If the system is running low on memory, UIImages that aren’t being shown on screen are purged, and reloaded from the file specified when needed.
At the moment I’m loading quite a few images and I’m concerned about memory management; it would be great if I can just leave the system to purge / cache as it sees fit, but I doubt that this is an effective solution. I’d appreciate any pointers / clarifications.
You’re reading it correctly. If you play around with scrolling very fast through the Pictures app, you’ll see that you sometimes beat the app, and come across a “loading…” swirl. Same with a UITableView… if an app’s running low on memory, it wipes out the image, and reloads it again when the user needs it.
For image scrolling, the UIScrollView memory management is pretty good; you can probably trust it to take care of memory management, in this case. If you try to do it yourself, or in some other way, you run the risk of a slow, jumpy UIScrollView, which is never good.