javaperformancejava-threadsthread-dump

Why is the VM thread slowing down my web application?


My Java web application is slowing down over a period of time. When I check the resource utilization, I find that the java.exe is consuming more CPU.

When I take the thread dump to analyse, the following thread is highlighted as the top consumer.

VM Thread" prio=10 tid=0x000000001ba2f000 nid=0x3504 runnable

What is the purpose of this thread? How and why is it slowing down my application and how can I arrest this?


Solution

  • This is a system thread; see What does java "VM thread" do? If it is consuming a lot of time, it probably means that your JVM is doing a lot of "stop the world" garbage collecting.

    If your JVM is spending a lot of time garbage collecting, that typically means that your heap is close to full and you are getting close to the point where you will get an OutOfMemoryError failure.

    There are two possible causes for this kind of thing:

    In the former case, you can either increase the heap size, or reduce the problem size, or modify the application to use memory more efficiently. Note that if you keep increasing the heap size, you will eventually have to worry if you have enough address space and physical RAM in your machine.

    In the latter case, you need to find and fix the bug or bugs on your application that are causing the memory leak. There are lots of articles on finding and fixing Java memory leaks.