Java
JDK 28 Cuts ZGC Startup Time by Moving Memory Setup Off the Critical Path
A new enhancement moves heap memory preparation to background threads, letting Java applications start faster without sacrificing warmup performance.
InfoQ
JDK 28 integrates JEP 545, a major optimization to the Z Garbage Collector that sidesteps a long-standing performance trade-off for Java deployments. Rather than force teams to choose between fast startup and fast warmup, the enhancement handles memory preparation concurrently, allowing both to improve simultaneously.
The Startup vs. Warmup Dilemma#
Until now, deploying ZGC required a difficult choice. The collector's pause times remain constant regardless of heap size, but its collection frequency rises as the heap shrinks—meaning applications with tiny initial heaps trigger garbage collection early and often. Teams seeking rapid startup would set -Xms to just 2 MB, then endure lengthy warmup periods as the collector acquired and prepared memory on demand. Teams optimizing for warmup would pre-allocate large heaps upfront—sometimes 32 GB or more—using flags like -XX:+AlwaysPreTouch to initialize all pages before the application started handling requests. The performance gap was substantial: roughly one-tenth of a second to boot with minimal memory versus more than ten seconds with a 32 GB heap on current hardware.
Moving Memory Work to Background Threads#
JEP 545 eliminates this choice by offloading memory preparation to dedicated concurrent worker threads called ZMemoryWorker, with one per heap partition. These threads commit, uncommit, and "heat" memory—pre-touching pages and collapsing small 4 KB pages into larger 2 MB pages—while the application runs. CPU usage for this work is capped at 25% of available capacity, as controlled by ZConcurrentWorkersCPUShare, preventing the background effort from starving the application or the collector itself.
On Linux 6.1 and later, the enhancement leverages the MADV_COLLAPSE mode for transparent large page support. Rather than requiring administrators to reserve large pages in advance, ZGC now probes for the capability at runtime, mapping a region, touching a page, and collapsing a 2 MB range to test whether the kernel supports the operation. If successful, the collector enters a Collapse state and upgrades pages in the background.
Practical Impact for Deployments#
The improvement is concrete. A case study using Spring PetClinic on a 32 GB machine showed a 38% reduction in startup time and warmup cut from 80 seconds to 10 seconds—all with a single flag: . This flag sets the initial heap to 2 MB and allows the maximum to scale to 100% of available system memory, letting concurrent expansion happen alongside memory preparation.

