2

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...

Urs
  • 21
  • 1
  • 2

2 Answers2

2

An application can use 30-40 MB of real memory or greater then this and there will not be a problem. When you are getting a memory warning level-1, till then there is not a problem, but if you get memory warning level-2, then the app might or will crash after some time.

solution is, when you get memory warning level-2, inside your delegate method, release some memory which you are not using currently.

1

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.

SteamTrout
  • 1,684
  • 1
  • 13
  • 9
  • 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 Aug 01 '10 at 16:21
  • Try using `isHidden` property and see if it helps. – SteamTrout Aug 01 '10 at 17:24
  • 1
    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 Sep 03 '10 at 22:37
  • 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 Oct 22 '10 at 17:56