Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Java Thread Dump in Android?

Tags:

java

android

dump

I just want to get all dumps from java virtual machine threads, to look at what the threads lock and what threads waiting to unlock some resources. Something like is described here. I've tryed to kill Zygote process but with no results.

like image 958
Divano Avatar asked Nov 27 '12 16:11

Divano


People also ask

How do you take a thread dump?

Ctrl + Break (Windows) In Windows operating systems, we can capture a thread dump using the CTRL and Break key combination. To take a thread dump, navigate to the console used to launch the Java application, and press the CTRL and Break keys together.

What is JVM thread dump?

A JVM thread Dump is a listing of the state of all threads that are part of the process at that particular point of time. It contains information about the thread's stack, presented as a stack trace.


2 Answers

If you don't have a rooted device and your app isn't a debug build, you can still generate a bug report from developer options to get the thread dump. The dumps are under the VM TRACES JUST NOW section of the bugreport*.txt file.

It's quicker if you know the ID of the thread you're suspecting. You can get the PID of the app by calling:

adb shell ps -A | grep com.example.myapp

and the thread ID with:

adb shell ps -T | grep <pid>
like image 175
black Avatar answered Sep 17 '22 14:09

black


Just debug your app on your phone in Android Studio; then in the "Debug view" Alt+5 just press the "Camera" button at the bottom left corner, to obtain a dump of all stacktraces, including locks they are holding.

like image 41
Martin Vysny Avatar answered Sep 20 '22 14:09

Martin Vysny