Longer Battery Life Means More Playtime
As you may already know, the Android OS is built on Linux, and as such, it contains some really handy utilities for controlling system performance. In order to perform the steps in this tutorial, you will first need to root your Android phone.
Those of us with a shiny new T-Mobile G1 will surely note that the stock battery tends not to last too long (or could it be that we’re using the phone so much due to its many versatile functions that we drain it too quickly?!?). Here is a solution that users with root access can try to extend the life of your phone when it is running on battery power.
By their nature, the following commands are not permanent. They go away after you reboot the phone. I honestly only ever restart my phone to test drive the latest ROM, but if you find yourself rebooting frequently, there’s a trick that will keep these settings even after a reboot.
Use adb remount, and then create a sysctl.conf file on your PC with the settings below, and then ./adb push sysctl.conf /etc/ and the kernel should apply the settings every reboot.
For examples of a sysctl.conf, use Google or Bing, or my favorite, Bingle.
Tweaking Virtual Memory For Battery Power
Open a Terminal and Execute these commands as root Tweak virtual memory to conserve power when running on battery:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap echo 0 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap echo 0 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap echo 60 > /proc/sys/vm/dirty_background_ratio echo 95 > /proc/sys/vm/dirty_ratio
Tweak Virtual Memory for Running on Charger
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap echo 3000 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap echo 500 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap echo 10 > /proc/sys/vm/dirty_background_ratio echo 40 > /proc/sys/vm/dirty_ratio
Detecting Apps/Services that Hog Battery/CPU
Also while on battery, you should stop all applications that don’t really stay idle when you’re not using them, if you want to find which apps aren’t really staying idle you can:
strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time
By default, when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.(this will also reduce cpu time and increase battery usage).
sysctl -w vm.oom_kill_allocating_task=1
Setting vfs_cache_pressure to 10 , gives more memory to cache fs dentry and inode to save cpu At the default value of vfs_cache_pressure = 100 the kernel will attempt to reclaim dentries and inodes at a “fair” rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.
sysctl -w vm.vfs_cache_pressure=10
Look for future updates as more techniques are discovered, and remember to commit these changes to sysctl.conf using adb in order to retain the settings after a reboot.


Will this work on Android 1.6 and on the Acer Liquid?