Search code examples
javavisualvmjvisualvm

Why is the heap utilisation increasing over time even if my program does not create any new objects?


This is a very basic question. But I am not getting any clear answer over internet. I have the following code

public static void main(String[] args) throws InterruptedException {
    Thread.sleep(1000000);
}

I connected JVisualVM and started monitoring the heap usage. I could see that the heap usage is gradually increasing over time. But, here I am not creating any new objects. What could be the reason behind this? Why is the heap utilisation increasing without the creation of any new objects?

Thanks in advance.


Solution

  • If you have connected with jvisualvm you should be able to see that there are many threads, not only the main application thread. Objects are created all the time. The profiler itself, for example, certainly creates objects. It is normal.