Skip to content
Advertisement

Criteria for default garbage collector Hotspot JVM 11/17

I found a source describing that the default gc used changes depending on the available resources. It seems that the jvm uses either g1gc or serial gc dependnig on hardware and os.

The serial collector is selected by default on certain hardware and operating system configurations

Can someone point out a more detailed source on what the specific criteria is and how that would apply in a dockerized/kubernetes enivronment. In other words:

Could setting resource requests of the pod in k8s to eg. 1500 mCpu make the jvm use serial gc and changing to 2 Cpu change the default gc to g1gc? Do the limits on when which gc is used change depending on jvm version (11 vs 17)?

Advertisement

Answer

In current OpenJDK, G1 GC is chosen by default for the “server class machine”, or Serial GC otherwise. “Server class machine” is defined as a system with 2 or more non-HT CPUs and 2 or more GiB RAM.

The exact algorithm can be found in src/hotspot/share/runtime/os.cpp:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement