Samsung Galaxy S6 To Receive Major Camera Update

When the Samsung Galaxy S6 and S6 Edge were launched, they became the prime focus for … more

Tactile: An Addicting Game with Beautiful Material Design

The game industry has been around for decades, catering to a wide … more

Android’s Consistency and The User Experience

This is a site of power users, and it is fair to say that most of us are more … more

Which Manufacturer (And Device) Made You Choose Android?

The beautiful thing about Android is that there is so much to choose from. … more
Thread Closed Subscribe to Thread Email Thread

[MOD] Improve your battery life

27th April 2012, 04:12 AM |#1  
Hero's Avatar
OP Recognized Developer
West Hollywood
Thanks Meter: 4,979
Donate to Me
Before we get to the mod, I want to get a little personal. I make these mods so that your Android experience will be enhanced. If you find something wrong with the mod then provide constructive criticism. Don't just sit there behind your computer and degrade the effects based on what you see in the code, especially if you are even unwilling to try the mod in the first place. That irritates the hell out of me and unfortunately, I can't help you with your do yourself and others a favor and either use the mod and provide constructive criticism such as results (positive or negative) or ways to improve it or don't use it at all. That being said, these tweaks work in conjunction with each other, they are not each meant to increase your battery life.

This is my mod for achieving good-great battery life. This is the mod I use in Anthem™ which has given me 50+ hours on a single charge. The increase in battery life may not be "tenfold" for you, but it does increase, which is still better than not increasing. Contact me before including it in your own ROM (that you plan on publicly releasing). I will allow you to use it, just ask first. Please give credit or thanks or both
First: Here is a flashable .zip of the mod that may or may not work with your ROM. I'd still advise doing it manually.

Sysctl.conf - Updated May 3, 2012
  • HTC Incredible (preferably)
  • Kernel with zram swap (for swappiness)
  • Kernel with init.d support

Currently working on:
  • HTC Incredible - Anthem, Clutch, AOKP, ICSenseless
  • HTC Amaze 4G

Step 1

Open up your (or whatever it's called) in 7zip (Windows) or Betterzip (OSX) and locate

sysctl.conf in /system/etc

If it's not in this directory, create it.

Step 2

In your sysctl.conf file, paste the following code and save it.

#sysctl.conf file
kernel.sem=500 512000 64 2048;
If the above code does not work for you, try this one. It has the semi-colons removed. Thanks Tiny

#sysctl.conf file
kernel.sem=500 512000 64 2048
Step 3

Now we need to enable it. So, navigate to /system/etc/init.d and create a file with the following code:

# grep sysctl /etc/init.d/*
# Load /sys/etc/sysctl.conf
sysctl -p
sysctl -p is what initializes the code.
Just FYI: You don't actually need these lines:

# grep sysctl /etc/init.d/*
# Load /sys/etc/sysctl.conf
So this would have just sufficed.

sysctl -p
If the above code does not work for any reason, try this:

sysctl -p /system/etc/
Name your file something like this 10sysctl

Save your file.

NOTE: Your ROM must support init.d. You can do this by using dsixda's android kitchen

Step 4

Save your ROM and install it via recovery


you could just push the files into your current ROM and try them out.

Credits to imoseyon for portions of the info

Ok, so what exactly is sysctl.conf?

The sysctl.conf is a configuration file for "sysctl" which is an interface for dynamically changing kernel parameters in the Linux OS. The configuration file contains the following elements, vm.min_free_kbytes, vm.dirty_ratio, vm.dirty_backgroud_ratio, vm.vfs_cache_pressure, vm.oom_kill_allocating_task. There are many other elements within the file, but we will be primarily focusing on these specifically (the vm prefix stands for virtual memory). The sysctl.conf file should be located in /etc (/system/etc) by default. To enable it you need your ROM to execute "sysctl -p" somewhere during the boot process (or shortly afterward). We will also be discussing how to enable it if it is not already done so. You can also run sysctl -p manually to enable it any time after the OS is started.

Now, let’s get down to what sysctl.conf does and how it works.

min free kbytes (vm.min_free_kbytes)
This is used to force the Linux VM to keep a minimum number of kilobytes free. The VM uses this number to compute a pages_min value for each lowmem zone in the system. Each lowmem zone gets a number of reserved free pages based proportionally on its size. Default is 2048kb.

dirty ratio (vm.dirty_ratio) and dirty background ratio (vm.dirty_background_ratio)
This controls how often the kernel writes data to "disk" (in our case the internal microSD system card, not the removable microSD card). When your apps write data to disk, Linux actually doesn't write the data out to the disk right away, it actually writes the stuff to system memory and the kernel handles when and how the data is actually going to be flushed to the disk. These values represent a percentage, the higher the percentage, the longer it waits to flush, the lower the percentage, the more often flushes will occur. Now remember, we are dealing with solid state storage, not the traditional disk platter and spindle. So we are actually able to delay flushes a little longer with solid state versus a traditional hard drive disk.

VFS Cache Pressure (vm.vfs_cache_pressure)
Now here is where it gets interesting! File system cache (dentry/inode) is really more important than the block cache above in dirty ratio and dirty background ratio, so we really want the kernel to use up much more of the RAM for file system cache, this will increas the performance of the system without sacrificing performance at the application level. The default value is 100, as a percentage, and what you want to do is lower the value to tell the kernel to favor the file system cache and not drop them aggressively.

oom allocating task (vm.oom_kill_allocating_task)(enable or disable, generally in Linux this value is either a "1" or a "0," representing as on or off.)
This enables or disables killing the OOM-triggering task in out-of-memory (oom) situations. If this is set to zero, or disabled, the OOM killer will scan through the entire task list and select a task based on heuristics to kill. This normally selects a rogue memory-hogging task that frees up a large amount of memory when killed. If this is set to non-zero, or enabled, the OOM killer simply kills the task that triggered the out-of-memory condition. This avoids the expensive task list scan, which can take mass amounts of time and "hang" or freeze the system.

block_dump (vm.block_dump)
This enables block I/O debugging when set to a nonzero value. If you want to find out which process caused the disk to spin up (see /proc/sys/vm/laptop_mode), you can gather information by setting the flag.

When this flag is set, Linux reports all disk read and write operations that take place, and all block dirtyings done to files. This makes it possible to debug why a disk needs to spin up, and to increase battery life even more. The output of block_dump is written to the kernel output, and it can be retrieved using "dmesg". When you use block_dump and your kernel logging level also includes kernel debugging messages, you probably want to turn off klogd, otherwise the output of block_dump will be logged, causing disk activity that is not normally there.

overcommit_memory (vm.overcommit_memory)
This controls overcommit of system memory, possibly allowing processes to allocate (but not use) more memory than is actually available.

0 - Heuristic overcommit handling. Obvious overcommits of address space are refused. Used for a typical system. It ensures a seriously wild allocation fails while allowing overcommit to reduce swap usage. root is allowed to allocate slighly more memory in this mode. This is the default.
1 - Always overcommit. Appropriate for some scientific applications.
2 - Don't overcommit. The total address space commit for the system is not permitted to exceed swap plus a configurable percentage (default is 50) of physical RAM. Depending on the percentage you use, in most situations this means a process will not be killed while attempting to use already-allocated memory but will receive errors on memory allocation as appropriate.

page-cluster (
This controls the number of pages which are written to swap in a single attempt. The swap I/O size.

It is a logarithmic value - setting it to zero means "1 page", setting it to 1 means "2 pages", setting it to 2 means "4 pages", etc.

The default value is three (eight pages at a time). There may be some small benefits in tuning this to a different value if your workload is swap-intensive.

panic_on_oom (vm.panic_on_oom)
This enables or disables panic on out-of-memory feature. If this is set to 1, the kernel panics when out-of-memory happens. If this is set to 0, the kernel will kill some rogue process, by calling oom_kill().

Usually, oom_killer can kill rogue processes and system will survive. If you want to panic the system rather than killing rogue processes, set this to 1.

The default value is 0.

Panic is a system error that is detected by the kernel.

dirty_expire_centisecs (vm.dirty_expire_centisecs)
How old "dirty" data should be before the kernel considers it old enough to be written to disk. It is expressed in 100ths of a second.

dirty_writeback_centisecs (vm.dirty_writeback_centisecs)
This is the interval of when the writeback daemons periodically wake up and write "old" data out to disk. It is expressed in 100ths of a second.
Last edited by Hero; 8th May 2012 at 02:17 AM.
The Following 92 Users Say Thank You to Hero For This Useful Post: [ View ]
27th April 2012, 10:42 AM |#2  
zombolt's Avatar
Senior Member
Thanks Meter: 42
I would be stoked if someone made a flashable zip for me to try

Sent from my ADR6300 using XDA
The Following User Says Thank You to zombolt For This Useful Post: [ View ]
27th April 2012, 12:48 PM |#3  
graymonkey44's Avatar
Senior Member
Flag New York
Thanks Meter: 383
Donate to Me
Could you please explain how this will increase battery life? And if it can be used in other phones?

Sent from my ADR6425LVW using XDA
27th April 2012, 01:23 PM |#4  
ferotakis's Avatar
Senior Member
Flag Sofia-Munchen-Venezia Santa Lucia - Ηρακλείου
Thanks Meter: 154
Does this work on x10 mini with miniCM by NAa ?
I have sysctrl.conf file and when open it with rootexplorer its empty .
Can I add this lines from phone ? Copy/paste them into the files whith rootex ?
Pls answer me and thk U .

Sent from my E10i using xda premium
27th April 2012, 01:42 PM |#5  
Senior Member
Thanks Meter: 35
how do we know if our rom has init.d support?
do we have to ask the rom creator or is there a way to check
27th April 2012, 02:06 PM |#6  
Senior Member
Thanks Meter: 21
Is this already included in your Clutch Rom as well?

Sent from my HTC Droid Incredible using XDA
27th April 2012, 02:57 PM |#7  
Recognized Developer
Thanks Meter: 4,635
Originally Posted by OMG_VTEC

how do we know if our rom has init.d support?
do we have to ask the rom creator or is there a way to check

You should have a line in /init.rc with busybox run-parts. To check the easiest way may be from the terminal:
grep busybox /init.rc
and look for a line like this:
service sysinit /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
27th April 2012, 03:33 PM |#8  
withbloodskies's Avatar
Senior Member
Flag Rancho Cucamonga
Thanks Meter: 516
Originally Posted by graymonkey44

Could you please explain how this will increase battery life? And if it can be used in other phones?

Sent from my ADR6425LVW using XDA

Trust me it works, I had over 20+ hours at a semi heavy use.

Sent from my ADR6300 using Tapatalk 2
27th April 2012, 04:37 PM |#9  
Junior Member
Flag Hendersonville, TN
Thanks Meter: 0
Originally Posted by withbloodskies

Trust me it works, I had over 20+ hours at a semi heavy use.

Was there any system performance degradation and/or instability?

Would someone knowledgeable be willing to give an overview description as to what the proposed changes effect?
27th April 2012, 04:50 PM |#10  
Thanks Meter: 10
Would also like to know if this could be done from phone.
Thread Closed Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes