Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Thread dumps containing monitors without locking threads

What could be the cause of JVM thread dumps that show threads waiting to lock on a monitor, but the monitors do not have corresponding locking threads?

Java 1.5_14 on Windows 2003

like image 219
Kevin Avatar asked Sep 15 '08 17:09

Kevin


2 Answers

Does your code by any change use any JNI? (i.e. are you running any native code launched from Java?).

We've seen a similar behavior, but JDK 1.6.0_05. App appears to deadlock, but Jstack shows threads waiting for a lock that no other threads are holding onto. We have some JNI code, so it's possible we're corrupting something.

We haven't found a solution for this and the issue is only reproducible on 1 machine.

like image 190
Joshua McKinnon Avatar answered Nov 14 '22 23:11

Joshua McKinnon


Do those waiting threads wait for ever, or do they eventually proceed?

If the latter, it may be that the lock is held by the garbage collector.

You can add the arguments -verbose:gc with -XX:+PrintGCDetails on your java command line to be told when GCs are occurring. If gc activity coincides with your slowdowns it may indicate that this is the problem.

Here's some information on garbage collection.

like image 32
tgdavies Avatar answered Nov 15 '22 01:11

tgdavies