Android adb shell and Studio view threads in App process (total and list)

First get the pid according to the package name

Command format:

adb shell "ps|grep com.xxx包名"

According to the package name, get the corresponding pid:
insert image description here

1. Obtain the thread list through the adb shell p command line

According to the above pid, execute the following command

adb shell  cat /proc/app的pid/status

View the total number of threads Threads:

insert image description here

2. Obtain a detailed thread list through the adb shell p command line

Get thread list via adb shell:

C:\Users\hexingen>adb shell
HWSPN:/ $ ps -T -p 17692

insert image description here

3. Monitor the thread status in the process in real time through the adb shell top command

The top command can display the status of each thread in real time. To enable thread viewing in the top output, call the "-H" option of the top command, which will list all Linux threads, and then combine to get the threads of the specified process:

C:\Users\hexingen>adb shell
HWSPN:/ $ top -H -p 19752

After execution, it will be refreshed periodically:

insert image description here

4. View through AndroidStudio profiler

It can only be seen by processes that need to be opened in debug mode.
Select the cpu sub-item, and the following interface will appear:
insert image description here
From the above, the total number of threads and the current existing specific threads can be known.

Guess you like

Origin blog.csdn.net/hexingen/article/details/131923763