views:

468

answers:

1

Hi Forum

I have an app that stacks quite a nice amount of views on top of each other.

At some point I receive a Memory warning level2 (which is kind of expected).

The thing is, when I run Instruments, I don't have any memory leaks and the app takes up something like 9-10MBs... which is not that much, I'd say?

Question is: how much memory can an app consume, a.k.a. how much RAM does the iPhone have?

I know that I can respond the the receivedMemoryWarning and free up some memory - but this would mean that I'd have to get rid of some of the views, which is not the solution I'm looking for...

The app didn't crash so far - but I'm concerned that it might crash on other user's iPhones...

A: 

You app won't crash anyone's iPhone. The system will just kill your app. Anyway 3GS is rumored to have 256Mb while iPhone 4 has 512Mb. It still won't matter because when you receive a warning you better comply. Try reducing the amount of views you have or unload the ones which the user can't see.

Steam Trout
Thanks for the clarification!Can't I just somehow «hide» the other views? They sometimes have certain states that need to be sustained. If I unload the view, it would lose its state as well...
Urs
Try using `isHidden` property and see if it helps.
Steam Trout
This is why it is always better to separate data objects from display objects.Try to plan your application the way that your data is seperated from the views so you can throw them away and create them later again when they are needed.You could also look into NSCoding to save the state of your objects.
Bastian
@Steam Trout: he didn't say he was afraid of crashing the phone, he said he was afraid of having the app crash.@Urs: You can see the rough specs of iPhones on this page, including RAM capacities: http://theiphonewiki.com/wiki/index.php?title=IPhone . The amount of available RAM depends on multiple factors, including whether the phone supports multitasking and thus if there are backgrounded tasks/suspended apps. On a typical iPhone 3G, an application will generally have no more than 15 MB of RAM available to it, and more likely will have less, with the rest taken up by Apple apps.
lensovet