Difference between revisions of "Android Notes"
(add some Android oom_killer info) |
(→oom killer info) |
||
| Line 15: | Line 15: | ||
Initial lowmemorykiller thresholds are set by /etc/init.rc (with the following lines): | Initial lowmemorykiller thresholds are set by /etc/init.rc (with the following lines): | ||
| − | + | ||
| − | # Define the oom_adj values for the classes of processes that can be | + | # Define the oom_adj values for the classes of processes that can be |
| − | # killed by the kernel. These are used in ActivityManagerService. | + | # killed by the kernel. These are used in ActivityManagerService. |
setprop ro.FOREGROUND_APP_ADJ 0 | setprop ro.FOREGROUND_APP_ADJ 0 | ||
setprop ro.VISIBLE_APP_ADJ 1 | setprop ro.VISIBLE_APP_ADJ 1 | ||
| Line 25: | Line 25: | ||
setprop ro.EMPTY_APP_ADJ 15 | setprop ro.EMPTY_APP_ADJ 15 | ||
| − | # Define the memory thresholds at which the above process classes will | + | # Define the memory thresholds at which the above process classes will |
| − | # be killed. These numbers are in pages (4k). | + | # be killed. These numbers are in pages (4k). |
setprop ro.FOREGROUND_APP_MEM 1536 | setprop ro.FOREGROUND_APP_MEM 1536 | ||
setprop ro.VISIBLE_APP_MEM 2048 | setprop ro.VISIBLE_APP_MEM 2048 | ||
| Line 34: | Line 34: | ||
setprop ro.EMPTY_APP_MEM 6144 | setprop ro.EMPTY_APP_MEM 6144 | ||
| − | # Write value must be consistent with the above properties. | + | # Write value must be consistent with the above properties. |
write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 | write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15 | ||
| Line 44: | Line 44: | ||
# Set init its forked children's oom_adj. | # Set init its forked children's oom_adj. | ||
write /proc/1/oom_adj -16 | write /proc/1/oom_adj -16 | ||
| − | + | ||
| + | Routines to actually calculate the oom_adj value, based on application state | ||
| + | are in the ActivityManager. See frameworks/base/services/java/com/android/server/am/ActivityManagerService.java:UpdateOomAdjLocked(...) | ||
| + | |||
| + | and | ||
| + | frameworks/base/core/java/android/os/Process.java:setOomAdj() | ||
Revision as of 21:06, 3 February 2009
Here are some miscellaneous notes on Android:
oom killer info
Google (Android) developer Arve Hjonevag added a lowmemorykiller feature to the staging area of the Linux kernel in January of 2009. This feature tries to reclaim memory before the system runs out (acting as a kind of cache manager, according to Arve). In Linus' 2.6.28-rc tree this appears in
Application lifecycle (and activity states) can be found here: http://code.google.com/android/intro/lifecycle.html
Applications in different stages of their lifecycle receive a different oom_adj value, which affects the probability of their being reaped.
Initial lowmemorykiller thresholds are set by /etc/init.rc (with the following lines):
# Define the oom_adj values for the classes of processes that can be # killed by the kernel. These are used in ActivityManagerService. setprop ro.FOREGROUND_APP_ADJ 0 setprop ro.VISIBLE_APP_ADJ 1 setprop ro.SECONDARY_SERVER_ADJ 2 setprop ro.HIDDEN_APP_MIN_ADJ 7 setprop ro.CONTENT_PROVIDER_ADJ 14 setprop ro.EMPTY_APP_ADJ 15
# Define the memory thresholds at which the above process classes will # be killed. These numbers are in pages (4k). setprop ro.FOREGROUND_APP_MEM 1536 setprop ro.VISIBLE_APP_MEM 2048 setprop ro.SECONDARY_SERVER_MEM 4096 setprop ro.HIDDEN_APP_MEM 5120 setprop ro.CONTENT_PROVIDER_MEM 5632 setprop ro.EMPTY_APP_MEM 6144
# Write value must be consistent with the above properties. write /sys/module/lowmemorykiller/parameters/adj 0,1,2,7,14,15
write /proc/sys/vm/overcommit_memory 1 write /sys/module/lowmemorykiller/parameters/minfree 1536,2048,4096,5120,5632,6144
class_start default
# Set init its forked children's oom_adj. write /proc/1/oom_adj -16
Routines to actually calculate the oom_adj value, based on application state are in the ActivityManager. See frameworks/base/services/java/com/android/server/am/ActivityManagerService.java:UpdateOomAdjLocked(...)
and frameworks/base/core/java/android/os/Process.java:setOomAdj()