JackWM
JackWM

Reputation: 10545

On Android, why the getRunningProcesses() returns much less than the TOP command?

When I used getRunningProcesses(), I got about 20~30 processes.

However, when I used the TOP command in an Android terminal, I saw more than 80 processes. I found some processes owned by "root" have zero memory consumption.

What cause the differences? Are some of the processes found by TOP not currently running?

Upvotes: 0

Views: 170

Answers (2)

nandeesh
nandeesh

Reputation: 24820

top shows all processes running on the operating system. Whereas ActivityManager.getRunningAppProcesses shows only processes started by Android.

Root owned processes are usually started by linux kernel for event handling , where as processes returned by ActivityManager.getRunningAppProcesses are only those started by Android framework

Upvotes: 1

ObAt
ObAt

Reputation: 2387

Android runs a lot of services. Those services you do not want to close because Android needs them to run. Here is some more information about services:

  • A Service is not a separate process. The Service object itself does not imply it is running in its own process; unless otherwise specified, it runs in the same process as the application it is part of.
  • A Service is not a thread. It is not a means itself to do work off of the main thread (to avoid Application Not Responding errors).

Also read Android Developers - Processes and Threads.

Upvotes: 0

Related Questions