views:

180

answers:

2

I'm reading some people stating that if another (3rd party) app on someone's iPhone has been leaking memory, that this may reduce the (mystery) amount of RAM your app would otherwise have available.

This confuses me -- does not all app memory get released when the app is closed by the user? And only one app is open at a time on iPhone?

+2  A: 

Normally, any memory that your application allocates will be freed when it exits. However, many of Apple's applications continue running after they're "closed", so memory leaks in Mail, for instance, can affect available memory.

In addition, there are apps out there that claim to free up allocated memory. They really don't do anything other than force some dirty pages out of the buffer cache, but they appear to do something, so people believe they must be doing something useful.

Mark Bessey
OK but just Apple apps -- not 3rd party? Can 3rd party apps have processes permanently running in the background, monitoring, waiting for something? What about this concept that apps can communicate with other apps now?
LouisLeaky
Nope, the notification service runs in the background, but that's just one process, which handles notifications for every app. Apps can really only communicate with each other by passing URLs from one app to another. The first app exits before the second one starts.
Mark Bessey
A: 

On a jailbroken phone - yes, third party apps can be running at the same time as yours. Running out of memory is common with people who like to have many apps running at once hence the need for task managers, killing tasks etc.

On an unhacked phone - no. Yours is the only non-apple app that is running, no others can run at the same time.

So what can you do? All you can do is try to use the minimum memory possible which you're probably already doing. Realistically you can only test with a factory, unhacked phone, unless you are going to spend hours trying to please everyone. If you think you are maybe using too much you could identify the larger allocations using the instruments tools ("Run with performance tool >" from within Xcode) and then post that chunk of code here to get ideas of how to reduce it.

Adam Eberbach
I'm not developing yet actually, just researching and curious. I certainly wouldn't worry about hacked phones. Is there nothing where one 3rd party app can have a process running in background that is always waiting for incoming mail or something?
LouisLeaky
An Apple task, yes - but your app doesn't have to deal with a reduced memory availability. It's part of the OS, overall memory availability takes this into account, etc. etc. Third party tasks, no.
Adam Eberbach
"Push Notifications"...?
LouisLeaky
OS reserves memory for what it needs to handle, you don't really need to worry about it reducing availability to your app.
Adam Eberbach
Apple background processes can leak. It's very frustrating too, because only 3rd party apps get killed when memory is low.
Rhythmic Fistman
Push notifications are not a 3rd party app running a process continuously in the background, to like check a Twitter account every 15 minutes and interrupt whatever you're doing on your iPhone with a notification that there's a new Twitter message?
LouisLeaky