Memory sampling with jvisualvm

一笑奈何 提交于 2019-12-22 11:24:01

问题


I am using memory sampling feature of Java Visual VM and I can't answer the questions:

  1. Why are there so many instances created?

  2. Why does these numbers of instances and bytes keep increasing?

For instance, I created a very simple Java program as follow:

public class TestMemory{
    public static void main(String[] args) throws InterruptedException {
        System.out.println("Hello");
        Thread.sleep(60 * 60 * 1000);
    }
} 

And I can see in Java Visual VM that there are 611 classes. The number of instances keep increasing from 25,000 up to near 50,000 and then fall back to around 25,000. The reason for the decreasing of instances might be caused by GC, but I don't know why those numbers are so dynamic even though I am not doing anything with my program.


回答1:


The number of instances and bytes that you are looking at is the cost of monitoring an app from VisualVM. VisualVM is polling various JVM MBeans, continuously to analyze the value change from your application.

To confirm this, you can go to the Sampler tab. Click on the Per thread allocation sub tab. See if the busy thread is RMI TCP Connection(n). This thread should have a high bytes allocation per second.

I was curious on how to optimize this too, hence posting a more specific question.



来源:https://stackoverflow.com/questions/14432445/memory-sampling-with-jvisualvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!