I am using memory sampling feature of Java Visual VM and I can't answer the questions:
Why are there so many instances created?
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.