Empty endless loop and GC (JVM). Please explain the effect.

My empty infinity loop

public static void main(String[] args) { while (true) {} } 

And profiling in Java VisualVM (picture) Visual gc

As you can see, I am not creating objects. Why change a bunch?

Please explain the effect. Why?

+6
source share
1 answer

Basically, any Java application is multithreaded, the fact that your main thread does not allocate memory does not mean that others do not allocate. In fact, it is very likely that by adding through VisualVM and showing the GC tab, you created some threads in the VM to monitor GC resources and submit VisualVM metrics that become those brilliant diagrams. And this monitoring is likely to allocate some of its own resources to carry out its work.

+7
source

All Articles