I am running a Java process with Xmx2000m, the host OS is linux centos, jdk 1.6 update 22. Lately I have been experiencing a weird behavior in the process, it becomes totally unresponsive with no apparent reason, no logs, no errors, nothing.. I am using jconsole to monitor the processor, heap and Perm memory are not full, threads and loaded classes are not leaking.. Explanation anyone?
- 1Impossible to answer. You need to identify where in your code the hang is occurring (Lots of logging may help here). Then maybe someone can help.Richard H– Richard H2010-12-07 12:29:27 +00:00Commented Dec 7, 2010 at 12:29
- I thought so. Just asking if anybody is familiar with debugging similar situations.Jad Y– Jad Y2010-12-07 12:55:30 +00:00Commented Dec 7, 2010 at 12:55
- Just recently, I had the same problem on several of my server applications. They had been running for years without problems. Then, one by one, stopped working. The first occurrence I can reconstruct by logs happened Nov 22 in 2020, the last around early December 2020. Didn't realize that all instances had that problem, found out one by one on different occasions. Could not even SIGTERM them, had to SIGKILL them. Scripts restarted them, any app that was manually restarted once has been running fine ever since...JayC667– JayC6672020-12-15 11:09:18 +00:00Commented Dec 15, 2020 at 11:09
7 Answers
I doubt anyone can give you an explanation since there are lots of possible reasons and not nearly enough information. However, I suggest that you jstack the process once it's hung to figure out what the threads are doing, and take it from there. It sounds like a deadlock or thrashing of some sort.
4 Comments
top or (my favorite) vmstat 5.Do a thread dump. If you have access to the foreground process on Linux, use ctrl-\. Or use jstack to dump stack remotely. Or you can actually poke it through JMX via jconsole at MBeans/java.lang/Threading/Operations/dumpAllThreads.
Without knowing more about your app, it's hard to speculate about the cause. Presumably your threads are either a) blocked or b) exited. If they are blocked, they could be waiting for I/O on a database or other operation OR they could be waiting on a lock or monitor (deadlocked). If a deadlock exists, the thread dump will tell you which threads are deadlocked, which lock, and (in Java 6) annotate the stack with where locks have been taken. You can also search for deadlocks with the JMX method, available through jconsole at MBeans/java.lang/Threading/Operations/find[Monitor]DeadlockedThreads().
Or your threads may have received unhandled exceptions and exited. Check out Thread's uncaughtExceptionHandlers or (better) use Executors in java.util.concurrent.
And finally, the other classic source of pauses in Java is GC. Run with -verbose:gc and other GC flags to see if it's doing a full GC collection. You can also turn this on dynamically in jconsole by flipping the flag at MBeans/java.lang/Memory/Attributes/Verbose.
Comments
Ok here are some updates I wanted to share:
There is an incompatability between NTPL (Linux’s new thread library) and the Java 1.6+ JVM. A random bug causes the JVM to hang and eat up 100% CPU.
To work around it set LD_ASSUME_KERNEL=2.4.1 before running the JVM, export LD_ASSUME_KERMEL=2.4.1 . This disables NTPL: problem solved!
But for compatibility reasons, I'm still looking for a solution that uses NTPL.
Comments
Check the jvisualvm of the process right before the crash. http://www.jadyounan.com/wp-content/uploads/2010/12/process.png
2 Comments
Could you elaborate more on what you are doing ? 2000 for memory is rather a lot.