Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Menneisyys2

macrumors 603
Original poster
Jun 7, 2011
6,004
1,108
Today, after promising some more info to fellow forum members here, I've played a bit with the different approaches to allocating memory under iOS.

During this, I've also played with the unnecessary daemons, which can safely be killed to free up some memory. As the vast majority of dedicated guides are heavily outdated (see e.g. the thread at http://insanelyi.com/topic/10792-kill-mailapp-itunesstored-safari-and-ipodapp-with-script/ - the script errorenously lists itunesstored as directly killable), I've decided to publish the results in a separate (this) guide.

Killing them can be done in both a shell script or, if you compile your app in Xcode, Objective-C. With the latter, just use the "system("killall -9 <daemon name>");" command; for example, "system("killall -9 medialibraryd");". (Note that you can use the same killall command to kill non-daemon apps. Then, you won't need to use the additional "-9". However, you definitely can use it if you want.)

On my rMini running 7.0.6, I was able to free up some 29M by simply killing the following unnecessary, memory-hungry daemons (typical memory usage on this iDevice model in parentheses). Note that I've listed the conditions of their automatic restarting (if at all). Of course 29M isn't much on an 1GB RAM device like the rMini; however, on more memory-constrained devices, freeing up 29M can dramatically increase the stability of the system. Note that these daemons are never killed by the system, unlike with top-level apps like Safari, Skype, Preferences and the like. Also note that I present you here with direct system calls you can quickly integrate into your compiled app. Finally, make absolutely sure you do follow the mini-tutorial of disabling MobileMail in the system-level Settings (right the first item below):

system("killall MobileMail"); // (13M) is automatically restarted until you disable the default "Push" under Mail, Contacts, Calendars > Fetch New data. Unfortunately, upon reboots, it's restarted even after disabling everything in Settings.

// daemons:
system("killall -9 medialibraryd"); // (5M): can be killed; automatically restarts when needed (e.g., when starting playback in the stock Music app)

system("killall -9 storebookkeeperd"); // (5M)

system("killall -9 itunescloudd"); // (1M). Note that itunesstored (13M)can't be easily killed and, it seems, it shouldn't be got rid of: this daemon seems to be quite important and not "just", say, an automatic downloader / update notifier; see http://nabla-c0d3.github.io/

system("killall -9 gamed"); // (10M) can be killed; upon starting a game using Game Center, it'll be restarted. However, until you kill and restart the game, you won't be able to use GC features. Starting the Game Center stock app also restarts it. Disabling the, by default, enabled two switches under Game Invites doesn't automatically disable the daemon – it must be done by hand.

system("killall -9 accountsd"); // (10-13M) it is always loaded, even if you don't configure any fb / twitter / vimeo / flickr accounts in Settings. If you kill it, it'll restart only when an app tries to actively query e.g. the Twitter account. (For example, when you explicitly tap the Twitter / FB icon in, say, Magzter > upper left menu > Invite Friends. That is, it can too be safely killed.

Hope you find this useful.

----------

You can also kill these daemons via SSH. Nevertheless, I'd still go the scripting / compiled binary way for easy execution.

The latter doesn't need special permissions - simply deploying from Xcode will gain you access to killall. (As the users of my previous JB camera tweaks may have already noticed this.)
 
You always provide amazing help and results. Thank you.

Doesn't Icleaner allow you to do the same things or am I missing the point of this post?
 
This is ridiculous. There's no reason to free up memory on iOS unless you are running a legacy device which is crashing from frequent page outs.
 
This is ridiculous. There's no reason to free up memory on iOS unless you are running a legacy device which is crashing from frequent page outs.

He says that he knows in his opening post

Of course 29M isn't much on an 1GB RAM device like the rMini; however, on more memory-constrained devices, freeing up 29M can dramatically increase the stability of the system.
 
I don't use any of the social services, wish you could perma kill accountsd. Not to mention MobileMail for push services. Such a waste for people like me.
Cool find though Menn.
 
People say it is not needed, but when it is low on memory the iPhone starts to get sluggish and animations stutter a lot more than usual... Kind of feels like using an android device.
 
Memory used up by stuff I'll never use is memory wasted. I can't think of a single reason why I would want that to happen on my device. I'll be the judge of what's needed and what's not.
 
I don't use any of the social services, wish you could perma kill accountsd. Not to mention MobileMail for push services. Such a waste for people like me.
Cool find though Menn.

Yup, the daemons not even configured or, in Settings, downright disabled (see push mail) are certainly a pain in the back.

Another VERY consumer-unfriendly app is Skype. As of the latest versions, its daemon is always loaded upon boot, even if you haven't provided your credentials (or, of course, if you've explicitly logged out, hoping it'd also get rid of the daemon) and it autostarts after killing. It occupies 18M RAM on all the platforms I've tested it on (5.1.1 on the iPad1/iPhone3GS and 7.0.x on the iPhone5/rMini) and it in no way can be easily disabled without some manual hacking (killall doesn't work as the daemon is restarted), other than uninstalling it from the system completely.

And, as it's a self-restarting daemon, you in no way can force it out of the memory. Which means you can safely allocate 155 / 167 MiB on an iPad1/iPhone3GS, both running JB'n 5.1.1 w/o resident JB apps like f.lux or SSH, from your own Xcode app "blindly", without ever crashing. With Skype installed those figures decrease to around 138 / 150M. (Figures tested and confirmed by me.)

----------

So do all this to free up 29MB of ram?
No thanks.

It's indeed not really worth the pain on 1GB devices. On 128M / 256M ones, it certainly is. And I have plenty of them around, handed out for my custumers for testing my apps on (I make sure all my AppStore apps run even on iPhone 3G's by excplicitly lipo'ing armv6 binaries with 4.0 deplyoment target to the compiled-for-iOS7 binaries I submit to Apple) and in the family, where I routinely hand down "old" models like the iPad 1 to relatives.
 
Last edited:
Another VERY consumer-unfriendly app is Skype. As of the latest versions, its daemon is always loaded upon boot, even if you haven't provided your credentials (or, of course, if you've logged in) and it autostarts after killing. It occupies 18M RAM on all the platforms I've tested it on (5.1.1 on the iPad1/iPhone3GS and 7.0.x on the iPhone5/rMini) and it in no way can be easily disabled without some manual hacking (killall doesn't work as the daemon is restarted), other than uninstalling it from the system completely.

This doesn't make sense, is against App Store rules, and isn't true. Skype does not have a daemon on iOS devices that starts every time the device is booted. It doesn't even have a daemon on Mac OS X (yet).
 
This doesn't make sense, is against App Store rules, and isn't true.

You mean adding armv6 binaries to fat binaries with lipo? It is NOT against the rules. Apple just made it impossible to compile for armv6 in Xcode 4.6+. However, a lot of us (look around StackOverflow for proof...) do provide armv6 binaries (together with at most 4.2 deployment target) so that we can make our apps iPhone 3G / iPod touch 2G and, if we can target pre-iOS4 (I can't as I extensively uses iOS4+-only blocks for threading), even first-gen devices.

Skype does not have a daemon on iOS devices that starts every time the device is booted.

it does. Check out yourself. I've did many times on 4 different devices & OS versions and I'm absolutely sure I'm right. The daemon is loaded without any human intervention (that is, starting the Skype app manually).

EDIT: now I see you referred to Skype's starting a daemon upon loading, and not the armv6 "hacking". It does load a daemon upon a complete reboot. I've just checked it on several iOS7.0.x / iOS5.1.1 devices again to be absolutely sure. I'll also check the system files loading it and report back.
 
Last edited:
You mean adding armv6 binaries to fat binaries with lipo? It is NOT against the rules. Apple just made it impossible to compile for armv6 in Xcode 4.6+. However, a lot of us (look around StackOverflow for proof...) do provide armv6 binaries (together with at most 4.2 deployment target) so that we can make our apps iPhone 3G / iPod touch 2G and, if we can target pre-iOS4 (I can't as I extensively uses iOS4+-only blocks for threading), even first-gen devices.

it does. Check out yourself. I've did many times on 4 different devices & OS versions and I'm absolutely sure I'm right. The daemon is loaded without any human intervention (that is, starting the Skype app manually).

Check what I quoted in my previous post. I did not quote anything about using lipo. The thing that is against App Store rules is having ones app start without user intervention. Skype does not do this. I have checked it myself as well, nothing there. May I ask what method you are using to obtain results that say it is?
 
Check what I quoted in my previous post. I did not quote anything about using lipo. The thing that is against App Store rules is having ones app start without user intervention. Skype does not do this. I have checked it myself as well, nothing there. May I ask what method you are using to obtain results that say it is?

Just check out the process list after booting up, even after explicitly signing out of Skype previously, before the reboot. It'll be there, consuming around 18 Mbytes (in my just-ran test, it consumed as much as 28M on the rMini).

This is why, BTW, Skype is able to receive calls after a cold boot w/o one's starting it via the SpringBoard icon. They may have a dedicated agreement with Apple to let their app register itself. Dunno as I haven't coded commercial VoIP apps so I don't really know how easy it is to get it run after booting.
 
Just check out the process list after booting up, even after explicitly signing out of Skype previously, before the reboot. It'll be there, consuming around 18 Mbytes (in my just-ran test, it consumed as much as 28M on the rMini).

This is why, BTW, Skype is able to receive calls after a cold boot w/o one's starting it via the SpringBoard icon. They may have a dedicated agreement with Apple to let their app register itself. Dunno as I haven't coded commercial VoIP apps so I don't really know how easy it is to get it run after booting.

You're not providing any reproducible tests to check for it. Here's one, SSH into the device right after it boots and run "ps ax | grep Skype". You'll get one and only one result, that result is the grep process finding itself. Skype is able to receive calls and such on a cold boot because of push notifications, not because it's running. If you get one, iOS will prompt you via the notification, but Skype still doesn't launch until to touch the notification or open it via Springboard. Apple doesn't have any agreement with Skype. It's a competitor's application that is competing with FaceTime and iMessages. The last thing Apple would want to do is give it an advantage over other App Store apps against its own services.
 
*sigh* People will obsess about RAM.

While most non-daemon apps, incl. stock ones like Safari, are killed when another app allocates large memory areas, some aren't. This means you'll NEVER be able to make use of those dozens of Megabytes from your own app as the memory they occupy will never be free'd.

Unfortunately, Apple (and some third parties' VoIP apps) load a lot of these daemons blindly. As I've pointed out above, MobileMail, accountsd, Skype, gamed etc. are loaded even without your configuring an account with them or even after completely disabling the functionality they'd be used for (Skype, MobileMail, accountsd etc.)

Getting these (mostly) daemons out of the memory can result in some major stability increase on low-memory (128 / 256M RAM) models.

----------

You're not providing any reproducible tests to check for it. Here's one, SSH into the device right after it boots and run "ps ax | grep Skype".

I listed it via "top". It also lists the memory usage (see the "rsize" column).

I've even made some memory allocation tests to see whether the 18M memory usage I've seen via "top" was indeed right. I've hard-coded a memory allocation of around 150 Mbytes (all figures are in MiB) on 5.1.1 iPhone 3GS and iPad 1 devices and fine-tuned the value until it stopped crashing on me during allocation.

With Skype installed, the highest "safe" memory allocation I could do was 138M / 150M on the iPad1/3GS, respectively. Trying to allocate, say, 140M on the iPad1 resulted in an instant app crash in 70% of the time, as opposed to the nearly-0% in the 138M case.

After uninstalling Skype, these "safe" figures have increased significantly, to around 155/167M, respectively. This does show Skype indeed did allocate itself the 18M memory I've spotted using "top", and it wasn't a false alarm.

If you want to play with this stuff yourself, I can quickly publish my allocation tester app's source code so that you can also run it.
 
I listed it via "top". It also lists the memory usage (see the "rsize" column).

I've even made some memory allocation tests to see whether the 18M memory usage I've seen via "top" was indeed right. I've hard-coded a memory allocation of around 150 Mbytes on 5.1.1 iPhone 3GS and iPad 1 devices and fine-tuned the value until it stopped crashed on me during allocation.

With Skype installed, the highest "safe" memory allocation I could do was 138M / 150M on the iPad1/3GS, respectively. Trying to allocate, say, 140M on the iPad1 resulted in an instant app crash in 70% of the time.

After uninstalling Skype, these figures have increased significantly, to around 155/167M, respectively. This does show Skype indeed did allocate itself the 18M memory I've spotted using "top", and it wasn't a false alarm.

If you want to play with this stuff yourself, I can quickly publish my allocation tester app's source code so that you can also run it.

top still doesn't show it, just as it should. Why is this point still being argued about? It is very clearly not allowed on the App Store. Please accept that you made a mistake about it and let it go. There is no Apple-Skype agreement, no built in Skype daemon, no fancy grey area workaround. It is not there. Let us ask Applejuiced or thelatinist to verify our findings by running "ps ax | grep Skype" on a freshly booted iOS device with Skype installed.
 
top still doesn't show it, just as it should. Why is this point still being argued about? It is very clearly not allowed on the App Store. Please accept that you made a mistake about it and let it go. There is no Apple-Skype agreement, no built in Skype daemon, no fancy grey area workaround. It is not there.

Again: it is there. I did test this with allocating as much memory as possible. With Skype installed, I did measure appr. 18M less usable (malloc-able) RAM.

This memory is simply lost for apps (incl. even memory-hungry stock ones like Safari) as, unlike third-party or most stock Apps (Safari, Camera etc.) these daemons are never killed.
 
Again: it is there. I did test this with allocating as much memory as possible. With Skype installed, I did measure appr. 18M less usable (malloc-able) RAM.

This memory is simply lost for apps (incl. even memory-hungry stock ones like Safari) as, unlike third-party or most stock Apps (Safari, Camera etc.) these daemons are never killed.

Do this and exactly this: SSH into an iOS device, run uptime then run "ps ax | grep Skype", post the resulting screen shot. Till then, you are incorrect with Skype autolaunching in any form.
 
Do this and exactly this: SSH into an iOS device, run uptime then run "ps ax | grep Skype", post the resulting screen shot. Till then, you are incorrect with Skype autolaunching in any form.

One moment. I may have made a mistake: I also have the Skype Recorder tweak on all those devices. (Some days ago, I've written an iPad-compliant configurer/tweaker for Skype Recorder. As I wanted to make sure it properly works on everything, I've installed it on most of my JB'n iDevices for testing. This is why it remained there.) Will promptly remove it and report back.

EDIT: BTW, here's the configurer I've talked about: https://forums.macrumors.com/threads/1713164/
 
Last edited:
One moment. I may have made a mistake: I also have the Skype Recorder tweak on all those devices. (Some days ago, I've written an iPad-compliant configurer/tweaker for Skype Recorder. As I wanted to make sure it properly works on everything, I've installed it on most of my JB'n iDevices for testing. This is why it remained there.) Will promptly remove it and report back.

EDIT: BTW, here's the configurer I've talked about: https://forums.macrumors.com/threads/1713164/

Tested it with the following config:

- both the latest iPhone version (4.17.2) and a late December one (4.15.329; this is one of the last versions to properly work with Skype Recorder after a respring / reboot, see my above thread), in addition to iPad version 4.13.428 (not the latest; as with the iPhone version, this is one of the last versions to properly work with Skype Recorder)
- manually disabling "Automatically log in" in the system settings (enabled by default)
- after removing Skype Recorder on all devices (no traces of the recorder anywhere).

Both ps and top still shows the Skype daemon after booting in, w/o tapping the Skype icon.

Tomorrow, I'll test all this on my non-JB'n iPad3. There, with the above-mentioned "let's find the maximal memory that can be allocated w/o frequent crashing with and without an installed Skype" approach to see whether there's a difference of about 20Mbytes in the two cases.
 
Last edited:
Tomorrow, I'll test all this on my non-JB'n iPad3. There, with the above-mentioned "let's find the maximal memory that can be allocated w/o frequent crashing with and without an installed Skype" approach to see whether there's a difference of about 20Mbytes in the two cases.

1. As promised, I've tested. The maximum memory I could safely (without any crashes during about 40-50 tests) allocate was 734 Mbytes. Anything over it (735+M) almost always resulted in crashes. This applies to both the Skype'ed and Skype-less version (Skype being the latest version).

That is, on a non-JB'n 7.0.6 iPad3, I couldn't measure the presence of the Skype daemon.

2. On a 4.3.3, freshly JB'n iPod touch 4G, with the latest available Skype version in the AppStore (the current one isn't 4.x-compatible any more), on which I've never installed Skype Recorder before, the usual happened: after a boot, even with everything disabled in Settings, the app is autostarted and it does occupy around 18-28M of RAM. Two screenshots are attached showing the process; one of them showing the app name & PID, the other one, shot in the legacy mode (available via 'x'), shows the memory usage found based on PID. (The RSIZE column couldn't be shown in its entirety in the non-legacy view in Portrait.)

That is, the pre-loading surely wasn't the fault of Skype Recorder.

It's also worth noticing that the Skype process was auto-started as the last one (PID = 169), before my manually starting Terminal, which received the next available PID; that is, 170. That is, it is autostarted by the system but at the very end of the bootup process and nothing is autostarted after it, at least not in such an old (and clean) system.

3, Dunno what the difference is caused by. Again, it was only on a non-JB'n device that I couldn't find any difference between the allocatable memory between the two states (Skype installed / not installed).

EDIT: continued playing. On JB'n devices, auto-loading the Skype process sometimes doesn't happen. I wonder if this is in some way related to push notifications?
 

Attachments

  • IMG_0007.PNG
    IMG_0007.PNG
    208.1 KB · Views: 159
  • IMG_0008.PNG
    IMG_0008.PNG
    203.1 KB · Views: 162
Last edited:
There is no Skype daemon. The directories where daemons exist don't have anything for Skype, only Apple things. Please stop with this nonsense as it is very clearly not allowed with the App Store rules.
 
There is no Skype daemon. The directories where daemons exist don't have anything for Skype, only Apple things. Please stop with this nonsense as it is very clearly not allowed with the App Store rules.

Yup, I've seen this myself - I've checked /System/Library/LaunchDaemons in the meantime.

Nevertheless, for some reason, the Skype process is started in many cases (on 4.3.3 at least) at the end of the boot process. Not as a daemon but as a full app. I'll report back.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.