3

I have a non-rooted phone. I just realized why Android is bad at memory management. I'm monitoring running progress in ADB shell with top. I can see the memory is about 100% used.

Image resized. Click for full-size

How do I stop unnecessary processes with ADB shell?

Also, I can't scroll down top command. It shows weird char ^[[b. I think that's because the shell uses sh instead of bash.

Any idea how to free up memory with ADB? Maybe pkill or what.

3
  • 1
    How to free RAM on Android?. Disclosure: This link belongs to me. Jul 15, 2023 at 14:19
  • You paid good money for a phone with all that RAM. Why would you want some of it to go unused? Jul 16, 2023 at 4:38
  • What is the android version? I see you have only 4 GB of RAM which is way too less for the apps in 2023. RAM consumption has increased drastically by apps. I have a 6 GB RAM phone which lags a lot as time goes on. To test (if possible) you can reset the phone once and check RAM usage. If it is similar then you need to upgrade your phone, Jul 17, 2023 at 6:58

1 Answer 1

8

Android memory management works differently than traditional OS. The main principle is to keep apps in RAM even if they are not used at the moment because the OS never knows when the user switches back to that app or the app becomes active in the background because of other reasons (e.g. incoming push message). Therefore, apps are kept in RAM unless another app really needs that RAM.

From the Android perspective, having free RAM means that RAM is unused and thus wasted.

It is because when an app has been removed from RAM, it needs to be loaded from flash and then perform the start-up phase. This will always be slower and consume more CPU resources (-> more battery usage) than just switching to an app that is already loaded and present in RAM.

However, RAM always takes the same battery no matter if it is free or used.

If Android OS needs RAM, then it simply closes or kills the oldest unused app (not sure how the OS RAM management decides which app to exit). All Android apps have to be implemented to be resistant to this out-of-memory exiting. In detail, the Android OS will first send a notification to an app it has selected to be exited. If an app receives this notification, it has a very small time span to do some clean-up. If the app does not respond in a certain time, Android will simply kill the app process and thus regain needed RAM.

As you can see, having a system with about 60-100 MB of free RAM is just normal on Android.

3
  • What is the point of leaving small free RAM such as 50MB? Jul 17, 2023 at 5:30
  • @MuhammadIkhwanPerwira Closing an app takes some time may be up to a second. If a foreground process needs more memory and the OS would need to first close apps for gaining the required small amount of RAM you would recognize that as a lag which is undesired.
    – Robert
    Jul 17, 2023 at 7:28
  • Comments have been moved to chat; please do not continue the discussion here. Before posting a comment below this one, please review the purposes of comments. Comments that do not request clarification or suggest improvements usually belong as an answer, on Android Enthusiasts Meta, or in Android Enthusiasts Chat. Comments continuing discussion may be removed.
    – Andrew T.
    Aug 26, 2023 at 5:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .