views:

103

answers:

2

What is the amount of memory an app can take before getting kicked by iOS? Does the amount of memory depends on the device version? I have developed an app which is using 30+ mb and its getting kicked on iPhone 2g. Can it work on iPhone 4 or 3GS?

A: 

All your application's resources on an iPhone 2 should probably stay at less than 20 MB. You can go a little over, but that's it, otherwise the memory warnings will occur. There's only 128 MB of total physical ram for everything - that's the OS as well as your own app.

Odi - Xceed
how about iPhone 3gs and 4
Ideveloper
+3  A: 

My experience with the iPhone 3G is that you should try to stay as small as humanly possible--build your data model with ditchability in mind, because you'll need to ditch. 20mb is bumping against the limit. 25 MIGHT be okay if the phone has been rebooted recently. You'll probably never get 30mb.

By contrast... I managed to prompt a memory warning on my iPhone 4 once, but it was due to an infinite loop bug that downloaded the same image file an infinite number of times. In other words, it took something REALLY drastic to crush the 4. Not that you can ignore memory management completely (a leak is still a leak), but for sure you've got some breathing room.

The 3Gs is somewhere between the two. I don't have one to test on, but I'd expect its performace is more 4-like than 3G-like, because while the on-board memory doubled from the 3G, the OS is still taking up the same space, meaning all of the new memory is yours to play with.

Dan Ray
Almost all of yours to play with.... the 3GS (and the iPhone 4) both have more features and those features require a bit more memory in the OS. Ultimately, though, it isn't that significant compared to the doubling of physical memory.
bbum
Don't forget about multitasking. As applications pile up in memory, the largest ones are terminated first, so it benefits you to keep your memory usage low in order for your application to hang around longer. Also, I've seen a hard ceiling of 30 MB for memory usage per application on the older iOS devices. One step above that results in instant termination.
Brad Larson
@Brad - Well that's true. Prunability of your data structure is a Good Thing no matter what sort of device you're on, and then just as important is understanding when and where to prune.
Dan Ray