Can someone suggest to me a way to count (inside an iOS app) all open apps on OS, to show to the user an alert if there's not enough memory to run my app?
Asked
Active
Viewed 236 times
1
-
@Jano: [Of course it's possible](http://forrst.com/posts/UIDevice_Category_For_Processes-h1H), but it's a very bad idea to do this. – DarkDust Nov 04 '11 at 09:57
-
I was wrong, testing with AppSwitch app the name of the application in the app store shows up along with the process id. And yes, I agree it's a bad idea, the system already closes background apps when it gets an urgent memory warning. – Jano Nov 04 '11 at 10:06
-
"the system already closes background apps when it gets an urgent memory warning": it's right, but sometimes, cause little amount of memroy, app freeze or bad, crash. – psico Nov 04 '11 at 13:58
1 Answers
4
While theoretically this is possible, it's not a good idea. First of all, the number of open apps is an inadequate measure when in fact you care about memory consumption. Next, this doesn't take into account the fact that different devices have different amounts of memory. Last but not least, if memory is running tight iOS will first kill background applications and free some memory for you.
So, don't do it. Instead, try to be a better iOS citizen: respond to memory warnings, try to cache stuff in files and read up on memory mapping (for example with mmap
) to reduce your app's memory footprint.

DarkDust
- 90,870
- 19
- 190
- 224
-
Tnks Dark, but I'm interesting in it cause i'm developing an enterprise app with a big amount of binaries and it's impossible to refactor the entire project. I totally agree with your opinion to be iOS compliant as regard memory, but I need this just to complete a workaround! – psico Nov 04 '11 at 13:54
-
Still, you're more interested in [querying the amount of free memory](http://stackoverflow.com/questions/2798638/available-memory-for-iphone-os-app), not how many apps are running. – DarkDust Nov 04 '11 at 14:51