diff options
Diffstat (limited to 'en/devices/tech/config/low-ram.html')
-rw-r--r-- | en/devices/tech/config/low-ram.html | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/en/devices/tech/config/low-ram.html b/en/devices/tech/config/low-ram.html index 10f1cbfc..100b4ab3 100644 --- a/en/devices/tech/config/low-ram.html +++ b/en/devices/tech/config/low-ram.html @@ -82,9 +82,11 @@ wrong thing). <code>ActivityManager.isLowRamDevice()</code> for applications to determine if they should turn off specific memory-intensive features that work poorly on low-memory devices.</p> -<p>For 512MB devices, this API is expected to return: "true" It can be enabled by - the following system property in the device makefile.<br/> -<code>PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true</code></p> +<p>For 512MB devices, this API is expected to return <code>true</code>. It can be enabled by + the following system property in the device makefile.</p> +<pre class="devsite-click-to-copy"> +PRODUCT_PROPERTY_OVERRIDES += ro.config.low_ram=true +</pre> <h3 id="jit">Disable JIT</h3> @@ -99,8 +101,10 @@ they should turn off specific memory-intensive memory usage, but if set too low will send the JIT into a thrashing mode. For the really low-memory devices, we recommend the JIT be disabled entirely.</p> -<p>This can be achieved by adding the following line to the product makefile:<br/> -<code>PRODUCT_PROPERTY_OVERRIDES += dalvik.vm.jit.codecachesize=0</code></p> +<p>This can be achieved by adding the following line to the product makefile:</p> +<pre class="devsite-click-to-copy"> +PRODUCT_PROPERTY_OVERRIDES += dalvik.vm.jit.codecachesize=0 +</pre> <h3 id="launcher">Launcher Configs</h3> @@ -136,7 +140,7 @@ using live-wallpaper. Low-memory devices should not pre-install any live wallpap <p>These thresholds can be configured via the framework config.xml</p> -<pre> +<pre class="devsite-click-to-copy"> <!-- Device configuration setting the /proc/sys/vm/extra_free_kbytes tunable in the kernel (if it exists). A high value will increase the amount of memory that the kernel tries to keep free, reducing allocation time and causing the @@ -148,7 +152,7 @@ by default. -1 keeps the default. --> <integer name="config_extraFreeKbytesAbsolute">-1</integer> </pre> -<pre> +<pre class="devsite-click-to-copy"> <!-- Device configuration adjusting the /proc/sys/vm/extra_free_kbytes tunable in the kernel (if it exists). 0 uses the default value chosen by ActivityManager. A positive value will increase the amount of memory that the @@ -172,7 +176,7 @@ memory or if more services have been added, the thresholds can be increased. </p backed pages, so that background processes are being killed long before disk thrashing would occur due to the cache getting too small.</p> -<pre> +<pre class="devsite-click-to-copy"> <!-- Device configuration setting the minfree tunable in the lowmemorykiller in the kernel. A high value will cause the lowmemorykiller to fire earlier, keeping more memory in the file cache and preventing I/O thrashing, but @@ -184,7 +188,7 @@ smaller buckets. -1 keeps the default. --> <integer name="config_lowMemoryKillerMinFreeKbytesAbsolute">-1</integer> </pre> -<pre> +<pre class="devsite-click-to-copy"> <!-- Device configuration adjusting the minfree tunable in the lowmemorykiller in the kernel. A high value will cause the lowmemorykiller to fire earlier, keeping more memory in the file cache and preventing I/O @@ -215,7 +219,7 @@ rendering times.</p> <p>To enable KSM, enable <code>CONFIG_KSM</code> in the kernel and then add the following lines to your` <code>init.<device>.rc</code> file:<br> -<pre> +<pre class="devsite-click-to-copy"> write /sys/kernel/mm/ksm/pages_to_scan 100 write /sys/kernel/mm/ksm/sleep_millisecs 500 write /sys/kernel/mm/ksm/run 1 @@ -249,29 +253,35 @@ system.</p> <li><code>CONFIG_ZRAM</code></li> </ul> </li> - <li>Then, you should add a line that looks like this to your fstab:<br /> - <code>/dev/block/zram0 none swap defaults zramsize=<size in bytes>,swapprio=<swap partition priority></code><br /> - <code><br /> - zramsize</code> is mandatory and indicates how much uncompressed memory you want - the zram area to hold. Compression ratios in the 30-50% range are usually - observed.<br /> - <br /> - <code>swapprio</code> is optional and not needed if you don't have more than one swap - area.<br /> - <br /> - You should also be sure to label the associated block device as a swap_block_device + <li>Then, you should add a line that looks like this to your fstab: +<pre class="devsite-click-to-copy"> +/dev/block/zram0 none swap defaults zramsize=<size in bytes>,swapprio=<swap partition priority> +</pre> + <ul> + <li><code>zramsize</code> is mandatory and indicates how much uncompressed memory you want the zram area to hold. Compression ratios in the 30-50% range are usually observed.</li> + <li><code>swapprio</code> is optional and not needed if you don't have more than one swap + area.</li> + </ul> + <p>You should also be sure to label the associated block device as a swap_block_device in the device-specific <a href="/security/selinux/implement.html"> - sepolicy/file_contexts</a> so that it is treated properly by SELinux. <br /> - <code>/dev/block/zram0 u:object_r:swap_block_device:s0</code><br /> - <br /> + sepolicy/file_contexts</a> so that it is treated properly by SELinux.</p> +<pre class="devsite-click-to-copy"> +/dev/block/zram0 u:object_r:swap_block_device:s0 +</pre> </li> <li>By default, the Linux kernel swaps in 8 pages of memory at a time. When using ZRAM, the incremental cost of reading 1 page at a time is negligible and may help in case the device is under extreme memory pressure. To read - only 1 page at a time, add the following to your <code>init.rc</code>:<br /> - <code>write /proc/sys/vm/page-cluster 0</code></li> - <li>In your <code>init.rc</code> after the <code>mount_all /fstab.X</code> line, add:<br /> - <code>swapon_all /fstab.X</code></li> + only 1 page at a time, add the following to your <code>init.rc</code>: +<pre class="devsite-click-to-copy"> +write /proc/sys/vm/page-cluster 0 +</pre> + </li> + <li>In your <code>init.rc</code> after the <code>mount_all /fstab.X</code> line, add: +<pre class="devsite-click-to-copy"> +swapon_all /fstab.X +</pre> + </li> <li>The memory cgroups are automatically configured at boot time if the feature is enabled in kernel.</li> <li>If memory cgroups are available, the ActivityManager will mark lower @@ -324,9 +334,11 @@ development/tools/findunused (should help make the app smaller).</li> <li>Don't enable code that is writing Parcel data to disk and reading it later.</li> <li>Don't subscribe to every package installed, instead use ssp filtering. Add filtering like below: -<br /> - <code><data android:scheme="package" android:ssp="com.android.pkg1" /><br /> - <data android:scheme="package" android:ssp="com.myapp.act1" /></code></li> +<pre class="devsite-click-to-copy"> +<data android:scheme="package" android:ssp="com.android.pkg1" /> +<data android:scheme="package" android:ssp="com.myapp.act1" /> +</pre> +</li> </ul> <h3 id="process-states">Understand the various process states in Android</h3> @@ -387,7 +399,7 @@ services include <code>batterystats</code>, <code>netstats</code>, <code>procstats</code>, and <code>usagestats</code>. You can find them with lines like this:</p> -<pre> +<pre class="devsite-click-to-copy"> ------ CHECKIN BATTERYSTATS (dumpsys batterystats --checkin) ------ 7,0,h,-2558644,97,1946288161,3,2,0,340,4183 7,0,h,-2553041,97,1946288161,3,2,0,340,4183 @@ -403,7 +415,7 @@ long running processes.</p> <p>Run for longer durations and track the memory of the process. Does it increase? Does it stay constant? Create Canonical use cases and run longevity -tests on these scenarios</p> +tests on these scenarios.</p> </body> </html> |