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.

Andrew T.
  • 16,898
  • 10
  • 77
  • 134

1 Answers1

9

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.

Andrew T.
  • 16,898
  • 10
  • 77
  • 134
Robert
  • 22,621
  • 6
  • 54
  • 76