Otherwise known as "Why Newer Android Phones Don't Need Task Killers".
This is straight ASCII cut-and-paste from my Evernote page, so any spelling and grammar mistakes are mine. I have looked over various apps such as AutoKiller, Advanced Task Killer, various threads on memory management in Android, even a few bits of Android source code. I know about compcache, minfree, swap, kernel, and more.
This is aimed at an Android owner who knows the basics, but is trying to optimize their device. They may have experimented with ROMs and kernels based on recommendations, but don't know about serious internal tweaking.
I realize what I wrote will probably have the techies screaming "no, no, that's not quite right"... That's why I want a tech review. If I had committed any serious misunderstandings, please let me know. If you have more references, please list them. Would prefer a bit more detailed comments than "sucks" or "great".
-------
Memory Management in Android: the myths and the facts
Introduction
The Android OS, now at V2.3 "Gingerbread", is widely misunderstood, due to lack of hardware specifications and the open nature of system, has created a wide set of myths regarding how the memory is managed, and how one can best achieve good performance on an Android device.
This article will attempt to explain just how Android OS manages memory, dispel some myths regarding Android memory, and show you some techniques that will help you keep your system running smoothly while achieving good performance.
However, first, here's some technical stuff about Android memory and applications. Trust me, all this is necessary to understand how the whole thing works.
Android OS Memory Management Basics
Android OS, as of V2.2 (and 2.3) have two general types of memory: internal storage (sometimes known as application stroage), and SD card (which may be flash memory that works like SD card, but not physical SD card, such as in the Nexus S)
All apps (in the form of APKs) are loaded into internal storage. Each program can also request additional space as "data" and/or "cache".
All apps (in the form of APKs) are loaded into "app storage" part of the "ROM" (actually flash RAM). Part of the ROM is the boot ROM which loads the system. The other half of the ROM is "app storage". For example, in Motorola Droid, 256MB is RAM, and 512MB is ROM. Out of 512MB ROM, 256MB is Android System itself (actually a bit less), and the rest is "app storage", to max of 256MB.
With Android 2.2 and "Move2SD", a portion of the APK can be moved onto the "SD card", but main portion must remain in internal app storage. The size of the main portion that stays would depend on the app. Some apps cannot be moved or will not function if moved. "Protected" apps cannot be moved. Apps that primarily consist of a service and a widget may not work if moved. add Services or widgets needed for startup should not be moved.
For example, If you have a 256MB system (shows as 262MB due to 1024 vs. 1000 KB size difference) and have 130MB of apps and data/cache loaded, then that leaves about 130MB for the system to actually RUN programs. That sounds like a lot, but in reality that is not enough, since the system itself takes 50-80MB, and services will take up another 30-50MB, leaving almost nothing.
addedIn a 256MB RAM phone such as my Moto Droid, AutoKiller shows...
acore : 4.55MB (system)
dialer: 8.95MB (system)
system: 20.38MB (system)
autokiller:5.68MB
messaging: 3.41MB (system)
Swiftkey: 6.59MB
JuiceDefender 4.14MB
Calendar Storage 4.1 MB (system)
acore: 7.7MB (different pid) (system)
smart taskbar 3.81 MB
seePU 3.44MB
Screebl 4.38MB
SetCPU: 3.83MB
ATK Froyo 3.01MB
gapps: 7.79MB (system)
and 2 more at 4.66MB and 3.56MB
That adds up to... 99.88, or 100 MB.
But that is supposed to leave 156MB, right? Wrong. The system itself takes about 100 MB by itself, in addition to loaded programs, according to this thread about T-Mobile G1 (which has 192 MB of RAM, and has about 96000 KB after booting)
UPDATE: I found an article that explains how to read "MEMINFO". You can get MEMINFO app, or if you have SetCPU the overclocking widget it shows MEMINFO as well. Mine says roughly:
MemTotal: 231740 KB, or 226MB
MemFree: 3376
Buffers 272
Cache: 34960
SwapCache: 0
So the system (before OS kernel) uses about 30MB leaving about 226 MB
Cache itself used another 35 MB. , leaving about 189 MB
Minus 100 MB of auto-loaded apps, and you get... 89 MB.
If you run any programs that need more than that, programs and services will be killed to make room.
(see Redhat's explanation on what meminfo is supposed to mean)
SIDEBAR: native vs. Dalvik
There are two types of Android programs... "Native" programs, and VM programs.
Native programs are written for the specific CPU in the machine. While this gives better performance, this is much harder to achieve, so most people write program for the VM, or "Virtual Machine".
A "virtual machine" is basically a CPU emulator. You feed it a program, and it will run this program, as if it's a real CPU. The good thing about using a VM is it doesn't matter what the actual physical CPU the device uses. You write the program once, and never have to worry about converting it to other CPUs.
Android's VM is called Dalvik, and it is similar to Java's virtual machine. (In fact, Sun/Oracle sued Google for violating Java copyrights on JVM)
Different pieces of a single app
Most apps have either just an activity, or activity along with a service.
"Activity" is basically the user interface that takes your inputs and displays something back. Foreground app would be an activity.
"Service" is a background program that updates something. Common services includes input, widget updates, mail notification, and so on. Other services include Bluetooth, network updates, and so on.
(Actually there are two more types: broadcast receiver, and content provider, but those are not that pertinent to our discussion)
An app can use a widget, and the widget can use a lot of memory, usually several MB at once. You can see the different services and how much memory they are taking under Settings / Applications / Manage Services
How Services Use Memory
As explained above, Android OS have to run programs from within the limited space available, which, on older phones, isn't much. From within that much memory, it needs system work space to load all the services (you probably have a dozen loaded, taking up at least 30 MB) System itself uses about 60-70 MB (acore, phone, gapps, messaging, etc.) That's 100 MB used. That doesn't leave much memory for anything else, if you have 100 MB of apps loaded. (256-100-100=56) 100MB for system itself, about 100MB used for apps and services, and you got almost nothing left.
If you look at the services screen, at the bottom, there's a bar: red, yellow, and green. There is a number in the red section and some in green. Your services adds up to the number in the green section. The yellow portion is some memory that can be freed. The red stuff are system stuff and can't be moved.
What Happens When System Runs Out of Memory
When the system needs to load programs, but don't see enough available, it will start killing programs and services (to the system, they are all considered "process") from memory based on the following priority:
Empty App: the app is in standby, not being used, but is still in memory. These can be killed without any effect.
Content Provider: process that provides content to the foreground, such as "contacts content provider", "calendar content provider", and so on. Various "storage" are also content providers. Those can be restarted when needed.
Hidden Application: apps not visible, but still running in the background. These are not exactly running, so killing them should have no serious consequences.
Secondary server: services that stay in background and apps such as Launcher (or other home replacements). Most services go here, like music player, clock updater, background sync, and so on, that's not built into the OS. If these are killed there may be some problems, such as the playback is interrupted, background sync stops, widget no longer updates, and so on.
Visible app: the app is running and visible, but due to multi-tasking or such is not currently "on top". Any program with a display in the notification area is considered "visible". Android OS will not kill these programs unless absolutely necessary, but it can happen.
Foreground app: you see this app on screen, currently running, but also includes the system itself and "phone". These are never killed. In any case, system and phone have much higher priority than any app to make sure those are never killed.
Each category above has a certain number associated with it, sometimes known as a "minfree" value (in either "pages" or megabytes, depending on the app). When Android OS free memory drops below the minfree value for that category, apps in that category are killed. The killing starts Empty App group as that has the highest number. if that's not enough, it then starts killing apps in the Content Provider Group, and it keeps going until it has finally freed up enough memory to load the app and all related processes (such as services).
NOTE: Having a constant "notification" in the notification area makes the program "visible app" instead of "hidden app", thus making it less likely to be killed by the system to make room for other apps.
A lot of problems with Android device occur when the system tries to make room by killing "secondary server" processes that are needed. Playback of audio (music or podcast) stopped, download stopped, location services stopped... etc. This especially happens on phones with little RAM. First Android phone, T-Mobile G1 / HTC Magic, has 192MB of RAM. Moto Droid have 256MB of RAM. Second generation of Android phones, like HTC Wildfire, got 384MB of RAM. Recent phones, like Droid X, Galaxy S, and so on got 512MB.
NOTE: Some apps, like web browser, can exit but still save the URL you were browsing. So when the process reloads, it is almost as if it was never unloaded. Unfortunately not all apps can do that.
So what is the solution?
There are two approaches to the problem: make more memory available, or pre-empt the auto-kill by killing apps yourself.
Making More Memory Available
There are four ways to make more memory available short of exchanging the phone for a more powerful one.
1) Free up more app storage / internal storage
Either uninstall the apps altogether, or move2sd as much as possible. Keep in mind move2SD may not work for all apps, and amount that can be freed varies greatly. Uninstall an app is best, as it both frees up the space itself takes, and if it loads a service, that service is loaded either, saving even more space.
While it's true that the app that wasn't run won't take up any space, every widget is served by a service, and a small app can load a HUGE service by calling existing libraries and declare a large buffer for downloads. And just because you don't actually use the app doesn't mean the system will not load it. The only way to make sure the app will NOT be loaded is to uninstall it (or if you have Titanium Backup premium, you can "freeze" the app)
2) VMHeap
VMHeap adjusts the the amount of memory that can be dedicated to the Dalvik Virtual Machine (VM). In general this should not be touched, and does not really make more memory available. It is available only for experimentation purposes.
This usually is NOT tweakable without mod ROM such as Cyanogen Mod. And benefits are unproven so far. Don't change anything yet.
3) CompCache
CompCache, or "compressed cache", is handled by the Linux kernel. It takes a portion of your memory, and use it as a cache space, but compressed. By using on-the-fly compression it is able to make your memory appear to be a bit larger than it actually is. However, the result is slower performance.
This is usually NOT tweakble without mod ROM such as Cyanogen Mod. The kernel also must support this feature, and not all do. This also slows your phone.
4) Swap file or partition
Linux kernel allows the OS to use the SD card as swap space by either creating a swap file or a swap partition. This adds a lot of read/write action to your SD card and may substantially decrease its usable life. However, it is a reliable way to "add" a lot of memory to your system.
Root access is required to swap the kernel, and the kernel must support this feature as well. Not all do. This really slows your phone. Beware.
Pre-emptive Killing of Tasks
The other way to avoid auto-kill is to kill the processes yourself via an app, so the auto-kill is not triggered. This is why apps like Advanced Task Killer and all the other "task killers" are created.
Basically, the task killers automate the task of killing apps, so it will free up memory thus auto-kill is NOT triggered. And because Task Killers have ignore lists, you can add your specific app to be ignored, and hopefully it will still run.
The best known one is ATK (advanced task killer) by ReChild, but there are plenty of others on the market. They usually have tweakable settings, like killing apps every time the screen is turned off (eeks!) or just at timed intervals (every 30 minutes), and so on.
On a phone with 512MB (or more) of memory, there should be no need for task killers, as the phone should not run out of memory. On phones with 256MB or less of memory, ATK may be necessary to keep the phone "free" for other apps.
Recommended Actions
If you have one of the older phones with little memory (256MB or less), load only the bare minimum of apps you need. uninstall the rest. You need to minimize your memory usage as much as possible to leave as much space for the apps. Keep 100-150MB available for the system is best. After system and services loaded, there should be at least 50MB left to load other programs and such.
You can use archivers like Titanium Backup or AppMonster to archive the apps to SDcard, and only reactivate them when you need them. Or you can delete them altogether, only redownload them from the Market when you need them. This will even work for purchased apps.
You can also purchase Titanium Backup which allow you to "freeze" apps, which makes leaves them in memory but NOT loaded. You can also uninstall built-in apps that you don't use, such as Amazon MP3, saving even more space.
If that is not enough. you can try using CompCache and/or Swap. However, those are not exactly recommended, and thus are only methods of last resort if you can't kill enough apps to matter. Try 18% compcache or even 26% compcache. If that doesn't help, try 128MB swap, or even 256MB swap if that still doesn't help.
For phones with 384MB or more RAM, you should not have to be so stingy, but no need to overload either. With extra 128MB -384MB you can load extra 50-100MB of apps and a few more services. The idea is still to keep 100-200MB available (depending on the phone). You do not need task killers and all that.
I was looking on the explanation for OOM priorities, and there it is. Thanks. I'm wondering why there are no replies to this thread. Oh wait, it's a question.
thanks for the most awaiting tutorial abt RAM.n yes i was wonderng y this thread hasnt got applause...
Such as the 512M memory replaced of 256M, the system remained stable,
I am currently from three directions,
(1) delete apk do not need to use in system\app
(2) delete services do not need in the SystemServer.java
(3) delete services do not need in the init.rc
there are other ways to reduce the memory?
THANKS.
Nope, that pretty much covers it. Don't worry about low memory, android is programmed to memory manage and kill background apps when it gets low
icenight89 said:
Nope, that pretty much covers it. Don't worry about low memory, android is programmed to memory manage and kill background apps when it gets low
Click to expand...
Click to collapse
I think that he is saying about ROM memory not RAM.
@fox19110324
I think that u can move cache to sd card
EDIT:
moving apps cache and dalvik-cache
@icenight89
I know what u mean.
But I really want to make sure the system can remain stable when I reduce the RAM from 512M to 256M,even 128M。
“android is programmed to memory manage and kill background apps when it gets low“。For example,when the RAM is lower than 15M,the system begin kill background apps。when the RAM is lower than 5M,the system begin kill Laucher app。
so....
@ch3mn3y
sorry,,I mean RAM...
noboby help me?...
Since I have installed "Autokiller memory optimizer", i have a new amazing device.
It is so much faster than before.
So try it out.
The only disadvantage of this program is, it is not so easy to understand with their settings. But take time, play with the app and you can have a new amazing device ;-)
FIRST: A WARNING
These apps require the phone to be rooted to be able to reach their full potential. And as they give you complete control over what to do, it's easy to get your ChaCha f****d up. So a backup with CWM Recovery is highly recommended.
We all know that the internal memory of the Chacha is low, and we are always struggling to have it controlled. Custom roms can make that memory to be really low when just installed, but continued use and trying apps make the memory to be filled with many files that are still there, even when you delete the app and the data associated to that app.
Many people likes to once a month or two, delete data and cache and start again, but for many of us, that's not an option because of the level of customization we have and must be repeated every time that operation it's done.
Enter these three apps, that well used can make you lower the used memory. They allows you to do a mix of regular manteinance and 'once in a while' operations.
AppCache Cleaner Makes easy to clear every day the cache files used by many apps like Market, Maps, Shazam!, and many others. Those cache files are secure and safe to be deleted. The app is easy to be set up and more easy to use. Also, an automatic clean every N time can be set.
SD Maid - System cleaning tool Makes the work of the previous app but with added functionalities, aimed to a less regular manteinance and deep clean. It can find corpses: data files of uninstalled apps that are there wasting space and many other things like log files, duplicated files... that are there making your ChaCha life harder. Some attention is required here because some operations, it not rightly done, can make you have a bad time because of deleting files you wanted not to delete, or that are essential files for your apps or system to run.
SystemCleanup This app is the most powerful of all and also the most dangerous. It has many of the features of the paid version of Titanium Backup, but for free. You can move apps from /system to /data, from /data to /system, odex and deodex them, move from/to sdcard, edit the autorun events they receive, freeze them, make backups... You can get rid of many of the bloatware the ChaCha comes with, and also decide what to do with those apps. The app itself give you directions on some apps that are safe to remove of required not to remove, but you are free to do what you want to with it, so attention must be put on what to do when using it.
I my self was able to remove about 60MB of useless stuff and the free memory jumped to a whopping 92MB of free memory after using them.
Take a look and have luck.
Titanium Backup ★ root - it allows You to "integrate app update to ROM" and save space in user storage.
Also it allows you to remove unused app from ROM and move "integrate" some aplications to ROM.
Most important would be app for recording Calls (both side), do Enyone know that software?
Clean Master is basically one of the best and most popular Android apps! The fact that it has average 4.7 rating from more than 18 million reviews speaks more than enough for its success. All that is deserved because it is one of the most comprehensive, broad and lovely Android tools. So helpful and filled with tons of useful features that will boost and speed up your Android device.
This app has several crucial features that are important for every Android device. First, this app is your App manager. You can install/uninstall or move any app from your phone’s memory to your SD card directly from the app. Additionally the app will manage your phone storage and SD card storage. It will constantly remind you if you are exciding storage space and it will constantly remind you to clear your cache and junk files. Also, it will remind you to move every new app you install to the SD card storage.
One of the best features of Clean Master is the ability to clear all the junk and residual files. This will save you tons of storage space. On one of my older devices that I have used in the last 2 years, Clean Master has saved me more than 15 GB of storage, isn’t that astonishing?
Clean Master cleans the junk files very fast. It can literally wipe up to 1GB of files in under 2 minutes. The residual files removal is also a great feature. Residual files are the files that the apps you uninstall leave on your phone. Clean Master easily gets rid of them and this increases the free storage space and speeds up your phone.
The app can also close any ongoing process and release RAM memory. The Clean Master’s widgets like 1 tap boost are really popular amongst Android users. This widget enables you to boost your phone with a simple tap on the icon.
Clean Master is the tool that I have used for the last 2 years and that I will continue to use in the future. It is highly reliable, extremely useful and easy to use. Get it for free and speed and clean your Android devices!
Read More ...Reviewappandroid.com
So, how much did CM pay for this?
ReviewApp Android said:
Clean Master is basically one of the best and most popular Android apps! The fact that it has average 4.7 rating from more than 18 million reviews speaks more than enough for its success. All that is deserved because it is one of the most comprehensive, broad and lovely Android tools. So helpful and filled with tons of useful features that will boost and speed up your Android device.
This app has several crucial features that are important for every Android device. First, this app is your App manager. You can install/uninstall or move any app from your phone’s memory to your SD card directly from the app. Additionally the app will manage your phone storage and SD card storage. It will constantly remind you if you are exciding storage space and it will constantly remind you to clear your cache and junk files. Also, it will remind you to move every new app you install to the SD card storage.
One of the best features of Clean Master is the ability to clear all the junk and residual files. This will save you tons of storage space. On one of my older devices that I have used in the last 2 years, Clean Master has saved me more than 15 GB of storage, isn’t that astonishing?
Clean Master cleans the junk files very fast. It can literally wipe up to 1GB of files in under 2 minutes. The residual files removal is also a great feature. Residual files are the files that the apps you uninstall leave on your phone. Clean Master easily gets rid of them and this increases the free storage space and speeds up your phone.
The app can also close any ongoing process and release RAM memory. The Clean Master’s widgets like 1 tap boost are really popular amongst Android users. This widget enables you to boost your phone with a simple tap on the icon.
Clean Master is the tool that I have used for the last 2 years and that I will continue to use in the future. It is highly reliable, extremely useful and easy to use. Get it for free and speed and clean your Android devices!
Read More ...Reviewappandroid.com
Click to expand...
Click to collapse
I was using Clean Master also
But with updating the app it become Hungry For Ram and Battery
So Does Battery Doctor now full of ads
The best CM app for now is CM browser
I switched from clean master to kk cleaner, has all the base features of cm but no ads or annoying pop ups, I would still be using cm if there wasn't all these self promoting ads or random articles. Sadly they think it was a great change as they have declared it a kind of "bonus feature" that they seem very proud of which is actually an annoyance and an issue leading to more RAM consumption, and more battery wasted as a result, and they have even been adding these things to their other previously great apps (ie. Battery doctor) so as an effect I have stored using all cheetah mobile apps and have found alternatives like kk cleaner
Clean Master works intelligently for removing virus, malware or any threat and there is no other lighter in weight application for Android Smartphones or Tablets that can take optimization of your Android devices to next level.
There are three things that will surely impress you or any other person.
1-Most of the people complain about Clean Master, that it eats lots of Battery Resources and which they are wrong about because it never occupies more than needed space, but people stuff their storage space with other useless space and blame CM for Battery and RAM consumption. I will vote it as light-in-weight app ever.
2- Sometimes, residual files that are most often pollute your devices without coming into your notice, but CM deletes them as easily as A-B-C, so never feel uneasy ' Clean Master is perfect Security guard for you'
3- Either it is PC or your Android Smartphone and Tablets, it is equally fruitful on all operating systems.:highfive:
Read More:
Download Clean Master (Boost & AppLock) APK For Android