Saturday, January 29, 2011

Android memory manager (low memory killer)

Android memory manager works pretty hard and is constantly killing processes in the background to ensure that you have enough memory to run your apps and also to keep the phone running snappy.

If you're as much of a control freak as I am, you kinda want to see which processes it's killing in the background.  It's actually pretty easy.  You can use either of the following methods:
  1. dmesg
  2. logcat
Both commands should give you similar output.  Here's what happens when I run it on my Droid X: 

bash-3.2# logcat -t 1000 | grep "has died"
01-29 15:01:09.577  1278  1283 I ActivityManager: Process com.motorola.calendar (pid 8595) has died.
01-29 15:07:46.957  1278  1278 I ActivityManager: Process (pid 8606) has died.

bash-3.2# dmesg | grep sigkill
<4>[58305.115783] send sigkill to 8595 (torola.calendar), adj 13, size 3198
<4>[58702.255462] send sigkill to 8606 (, adj 14, size 2942

Nice thing about using logcat is that it gives you readable timestamps, so you know exactly when they were killed.  Since I'm a bit OC, I have a script that runs both:
bash-3.2# cat
# tells me which recent processes were killed by lowmemkiller

echo --- using dmesg ---
dmesg | grep sigkil
echo --- using logcat ---
logcat -t 1000 | grep "has died"


  1. Companies are hiring android developers on their capabilities of developing new and innovative android application and not on any other criteria. Android training do not takes long time but students must make sure that they must learn Java basic before going for android training.prompter