How much memory does iOS allow apps to use?
Asked Answered
I

1

7

I am making an app that uses a lot of fairly big image files. I notice it crashes when they all get loaded on my iPhone 3G (128 mb ram), but not when I test it on a 3rd gen iPod (256 mb ram). So I assume there must be some percentage that is allowed for each app to use? My app has about 30 images at about 440k each loaded so 13.2mb. I didn't think that would be too much. They need to be swapped in and out pretty quickly, so releasing the ones not in use from memory doesn't seem like a good idea...

EDIT:

The app swaps images based on the way the phone is being tilted. It's 30 images from a 3D scene, so when you move it, it changes the perspective. It needs to be as smooth as possible.

Iggie answered 12/11, 2010 at 23:25 Comment(4)
I believe it's worse than you think: A UIImage, once loaded, is probably going to take the uncompressed size rather than the compressed size. You should probably use Instruments to see how much memory you're actually using.Bubalo
How fast is "pretty quickly"? Anything other than realtime fast switching is pretty irrelevant. Toss us a couple more details on how fast, and why you need these images in memory, because right now, it's kinda hard to grasp the use case of requiring so much memory at one time.Brewmaster
You're gonna have to bite the bullet. Having a less responsive app is still better than one that crashes. Still, look at scaling down the images, and at ways you can save memory. There's definitely ways you could do loading on demand without blocking the UI, such as preloading the images that are close to the current viewpoint, while releasing the ones that are way out of sight.Brewmaster
I feel kind of silly that I spent 2 days on this but...the images the guy sent were for the iPad version, not iPhone. So they were 2 over 2 times too large...ah well...works fine now.Iggie
B
10

The answer is: as much as you want, until the OS complains.

There is no such thing as an absolute memory limit, since it wholly depends on the phone's memory, how much the OS and its related services are taking up, and the time of the month (just kidding, but you get the idea).

You should be scaling down these large image files to fit into memory, or even more so, not loading them all at once considering the screen is so small and only so much can be viewed at any one particular time.

Brewmaster answered 12/11, 2010 at 23:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.