Search code examples
iphoneiosxcodexcode-instruments

Xcode - Iphone Memory limitation


What is the maximum memory one application can use? Please find instrument screenshot with this message. What is this real memory and virtual memory limitation?

screenshot


Solution

  • I don't think I can answer your question directly, but a few thoughts:

    1. In terms of physical RAM available, as you can see from the Wikipedia overview of iPhone models, it varies from 128MB for original iPhone and the 3G, 256MB for the 3Gs, and 512MB for the 4 and 4S.

    2. According to Apple's iOS App Programming Guide, virtual memory isn't paged memory from physical disk/storage (like you see in a desktop OS), so I would have assumed that iOS is simply allocating physical RAM as virtual memory to the apps, less that consumed by the OS (and any background apps). Also, see Apple's discussion of virtual memory in their Memory Usage Performance Guidelines.

    3. Finally, see this SO post about determining the available memory. As way of a data point, on a development 3GS running iOS 5.1.1, the algorithm in that SO post is reporting ~228MB total available memory with ~100MB free (in a fairly simple storyboard ARC test project with a ton of view controllers, of which only two are actively used at the point of testing the available memory). If this is any indication, it looks like it yields much of the physical RAM, presumably using some of the memory for iOS apps like SpringBoard and the like. If I ran other user apps in the background, the memory reported by my test app was accordingly diminished (both the total "available" and "free" ... e.g. with Facebook running in the background, I lost 20-30MB), but if I terminated the other apps manually, the memory was recovered and available to my memory testing app. I assume if the memory available for my current app was sufficiently diminished, iOS would have dismissed those other apps running in the background for me, but I didn't test that.

    Bottom line, it looks like the memory available to an app seems to be a function of (a) physical RAM dictated by the particular model of the device; and (b) what other apps are still running in the background.