Java 12 introduces multiple enhancements to its garbage collection algorithms.
An experimental Low-Pause-Time Garbage Collector, Shenandoah is introduced to reduce the GC pause time. It works in parallel with running java threads. This helps to reduce the dependency of GC over heap size and makes it consistent. Now Garbage collection pause time would be similar for 2 MB as well as for 2 GB heap sapce.
Shenandoah is expected to be part of main JAVA release with Java 15.
With Java 12, G1 will process java heap space if application is inactive and may release the memory to operating system. This preemtive behavior conserve and free memory.
With Java 12, G1 efficiency has been improved. Now G1 mixed collections are abortable if they exceed the define pause limit. Now mixed collections are spilt into mandatory and optional. G1 collector can prioritize the mandatory sets to be check the pause time goal.