Giter VIP home page Giter VIP logo

prlmk's Introduction

prlmk

A custom low-memory-killer for Android, based on the process reclaim driver. Primarily suitable for devices with 4GB ram or less.

usage

  • Disable all other low-memory-killers, if previously enabled, in the defconfig, for example:

CONFIG_ANDROID_LOW_MEMORY_KILLER=n

CONFIG_ANDROID_SIMPLE_LMK=n

  • Enable the following in the defconfig:

CONFIG_PRLMK=y

  • Make sure ZRAM/SWAP is enabled, otherwise you may encounter serious problems when using the driver. A ZRAM disksize/SWAP size of 1GB or higher is preferred.

  • Apply all the process_reclaim and prlmk commits from the branch that correlates to your kernel version and compile.

objective

  • Keep important tasks like Android services running until they are closed by the user.

  • Kill apps as little as possible, or specifically, killing apps based on the total time spent on it. This means that, apps with larger usage time get killed more rarely, and apps with lesser usage times get killed frequently.

approach

  • We keep reclaiming pages if they are above defined threshold (free_swap_limit).

  • Once the swap goes below free_swap_limit, we start to collect tasks to kill.

  • We then sort those tasks based on their last accessed stime+utime, and then start killing the tasks with the lowest stime+utime. We stop killing tasks once the number of swap pages are above the threshold (free_swap_limit).

  • If the number of active file pages go below free_file_limit, it means that a memory critical situtation has occured, and tasks will be killed more aggressively.

    I specifically sorted according to acct_timexpd, see kernel/tsacct.c for more details (CONFIG_TASK_XACCT).

additional info

The default settings in this driver are already suitable for 3GB and 4GB RAM devices, there is no need to extensively tune it.

Should you feel the need to tune it, however, enable the DEBUG option in the code, like this:

#define DEBUG 1

and compile and boot the kernel. Try to stress memory as much as possible, by loading lots of applications and/or using a memory stress-tester tool, and carefully analyze dmesg and the log messages that follow. This will help to fine-tune free_file_limit and free_swap_limit.

credits

prlmk's People

Contributors

darkhz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.