Sobes.tech
Junior — Middle

How does the Android operating system choose which process to terminate first when resources are scarce?

sobes.tech AI

Answer from AI

Android chooses processes for termination based on resource shortage, guided by process priorities determined by their state and importance to the user. The main mechanism is the Low Memory Killer system, which classifies processes:

  • Foreground process — actively interacted with by the user. They have the highest priority and are rarely killed.
  • Visible process — visible to the user but not in the foreground.
  • Service process — running services not visible but important.
  • Background process — not visible and not performing critical tasks.
  • Empty process — no active components, first to be killed.

When memory is low, the system kills processes starting from the lowest priority (empty, background), gradually moving to more important ones if more resources need to be freed.

This approach aims to preserve user experience by killing processes that least affect current user activity.