Skip to main content
Participating Frequently
November 16, 2012
Question

iOS - Retain images in memory

  • November 16, 2012
  • 2 replies
  • 580 views

I'm in the early stages of developing an iPad app with heavy, high res imagery for the retina display. While using the app, the performance is great. Once the user pauses for about 5-10 seconds, the app stutters for a second or two at the next interaction.

Using Instruments, I've tracked it down to what seems to be a memory issue. With all images loaded and animating smoothly, the app uses ~140MB of memory. After the user has paused, the memory usage drops to ~67MB. When the user interacts again, the stutter is apparent as it re-loads all of the same images back into memory and again sits at ~140MB.

While I can make some image optimizations to decrease the amount of memory used, is there any way to flag these images (which are part of a constant user interface) as important so that iOS doesn't purge them from memory?

This topic has been closed for replies.

2 replies

Participating Frequently
November 19, 2012

I stumbled upon the below post which is the exact issue I am talking about. I'll try the hacked solution and see if it works for me as well.

http://forums.adobe.com/message/4462450

Participating Frequently
November 19, 2012

Update:

Keeping the mentioned stats running in the background DID resolve the issue for me as well. My guess is that because its constantly updating the graph it prevents whatever "sleep mode" AIR seems to activate.

With the fix in place, I did some additional testing with Instruments. I saw that as long as graphic elements remained visible onscreen, they would remain in memory, preventing the undesirable hiccup I first mentioned. Setting an items alpha to 0 seems to allow it to be removed from memory during idle, again causing the hiccup as it was loaded back into memory. So in cases where I wanted elements hidden but to remain in memory I've simply positioned them off stage.

While this workaround takes care of the issue, it'd be great to hear from someone at Adobe about what's going on behind the scenes and even better if we could get some level of control over which elements are purged from memory during idle periods.