High CPU in "VM Thread" in Java application
Environment
- OpenJDK
- Oracle JDK
Issue
- My Java application is using a lot of CPU time, and there is a single thread called "VM Thread" that is using ~100% cpu. Why is this occurring?
Resolution
Inspect the GC logging and heap dump to determine if the excessive GC is due to an undersized heap or unintended object retention.
Root Cause
The high cpu is due to garbage collection or another JVM operation that requires a safepoint: Deoptimization, PrintThreads, PrintJNI, FindDeadlock, ThreadDump, EnableBiasLocking, RevokeBias, HeapDumper, GetAllStackTrace.
Diagnostic Steps
- Captured thread dumps and
topdata to see the high CPU usage. - Request a heap dump and GC logs from the time of the issue.
- Check if a significant amount of stopped time is not GC related.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.