Is gc always invoked, even when the heap is constantly available at runtime?

According to the Java Platform Standard Edition HotSpot Virtual Machine Garbage Collection Tuning Guide Generations section

When the young generation is full, it causes a small collection, in which only the young generation is assembled.

and

In the end, the generation of generations will be filled and must be collected, as a result of which the main collection will be collected, in which the whole pile will be collected.

So, if the application has completed the distribution phase, and during the execution of the application, the young and generational generations are never filled (in general, at any stage), then gc will never occur?

If this happens, what is the reason? Because it contradicts related documentation.

+5
source share
1 answer

So, if the application has completed the selection phase and throughout the entire application execution the young and experienced generations were not filled (in general, at any stage), will gc never happen?

Yes. If young and generational generations are not filled (at any stage), then gc may not occur (even once). This is up to the JVM runtime environment for managing memory, and this includes deciding when (or if) garbage collection occurs.

+6
source

Source: https://habr.com/ru/post/1239596/


All Articles