javajvmdeadlockthread-dump

Java thread dump analysis: how can I find more information about objects on which deadlock is happening?


I have a Java Thread Dump which clearly says I have a deadlock in my application:

"pool-2-thread-1":
  waiting to lock monitor 0x00007f17b0040120 (object 0x00000000f731a9e0, a com.MyClass),
  which is held by "pool-6-thread-1"

"pool-6-thread-1":
  waiting to lock monitor 0x00007f17b803cfc0 (object 0x00000000f72e7e90, a com.MyOtherClass),
  which is held by "pool-2-thread-1"

Now I want to understand which particular objects are locks, these two threads a waiting for. I have class names, but there are many instances of this type in my application. I want to understand which particular instance is causing this issue. The ideal way for would be to print toString() for that instance.

So the questions are:

  1. what does "0x00007f17b803cfc0" mean?
  2. how can I establish a relation between "0x00007f17b803cfc0" and an object in my JVM?

Solution

  • 0x00007f17b803cfc0 is the address at which the object is located in memory. You can make a heap dump and then find this object using a dump analyzer.

    To make a dump you can use the jmap command, to find an object at an address you can use VisualVM.

    Here is an example of getting a dump.

    jmap -dump:live,format=b,file=heapdump.hprof <PID>