Nicolai ParlogHost
Adaptive heap sizing, which aims to give you a better balance between CPU use and memory consumption with close to zero configuration.

Put simply, the goal of any GC is to allow the application to keep allocating memory and there are three currencies it takes as payment for this service.

GC pauses, when the collector needs to stop the application, CPU utilization, which allows the GC to do its work, and of course memory.

ZGC specifically aims at ultra-low pause times, so we won't be paying much out of that pocket and we can cross it off the list.

This leaves us with CPU, which ZGC uses concurrently with the running application, and memory.

The essential observation about these two factors is that you can pay ZGC in a mix and the more you pay off one, the less you need to pay off the other.

That's because the work that goes into freeing up memory does not depend on the amount of freed or available memory, but only on how much of it is usefully occupied.

This so-called life set depends on the app itself and barely on the heap size.

App-level caching and weak references complicate this a bit, but we can ignore that here.

So every GC cycle requires a certain amount of CPU time, but the more heap space you have, the more time goes by between cycles and thus the lower overall GC CPU utilization.

If you have a CPU-intensive application on a system with a lot of free memory, let it be heap-size.

If memory is scarce, maybe due to the hardware itself, other services on the system or an allocation spike in your app, you pay with more CPU.

What if, over an application's lifetime, you wander between these poles? And here we finally come to adaptive heap sizing.

In a nutshell, if you activate this JDK28 feature with plus use ZGC plus Z adaptive heap sizing, ZGC observes the application and the system and balances these factors out.

If the application is keeping the CPU busy and memory is available, ZGC will expand the heap to minimize its own CPU demands.

To make the most of the available resources, this can go up to almost 100% of the system's memory if it doesn't push back through its own demands.

But when it does and memory pressure rises, particularly while the app's CPU needs are low, ZGC aims to clear out memory and return it to the OS.

There's a single abstract setting plus ZGC intensity, which allows us to configure the trade-off with a positive number.

The lower the value, the less intensively ZGC works, i.e. the less CPU but the more of the available memory it will try to use.

At zero, adaptive heat sizing would never use more CPU than it absolutely has to, so it'd effectively be turned off.

The JVM will instead reset it to its default value 5 and tell you as much as a log message.

Beyond 5, the CPU gets ever busier in exchange for using less and less memory beyond the live set, but expects starkly diminishing returns as the value grows.

Adaptive heap sizing, which aims to give you a better balance between CPU use and memory consumption with close to zero configuration.

Put simply, the goal of any GC is to allow the application to keep allocating memory and there are three currencies it takes as payment for this service.

GC pauses, when the collector needs to stop the application, CPU utilization, which allows the GC to do its work, and of course memory.

ZGC specifically aims at ultra-low pause times, so we won't be paying much out of that pocket and we can cross it off the list.

This leaves us with CPU, which ZGC uses concurrently with the running application, and memory.

The essential observation about these two factors is that you can pay ZGC in a mix and the more you pay off one, the less you need to pay off the other.

That's because the work that goes into freeing up memory does not depend on the amount of freed or available memory, but only on how much of it is usefully occupied.

This so-called life set depends on the app itself and barely on the heap size.

App-level caching and weak references complicate this a bit, but we can ignore that here.

So every GC cycle requires a certain amount of CPU time, but the more heap space you have, the more time goes by between cycles and thus the lower overall GC CPU utilization.

If you have a CPU-intensive application on a system with a lot of free memory, let it be heap-size.

If memory is scarce, maybe due to the hardware itself, other services on the system or an allocation spike in your app, you pay with more CPU.

What if, over an application's lifetime, you wander between these poles? And here we finally come to adaptive heap sizing.

In a nutshell, if you activate this JDK28 feature with plus use ZGC plus Z adaptive heap sizing, ZGC observes the application and the system and balances these factors out.

If the application is keeping the CPU busy and memory is available, ZGC will expand the heap to minimize its own CPU demands.

To make the most of the available resources, this can go up to almost 100% of the system's memory if it doesn't push back through its own demands.

But when it does and memory pressure rises, particularly while the app's CPU needs are low, ZGC aims to clear out memory and return it to the OS.

There's a single abstract setting plus ZGC intensity, which allows us to configure the trade-off with a positive number.

The lower the value, the less intensively ZGC works, i.e. the less CPU but the more of the available memory it will try to use.

At zero, adaptive heat sizing would never use more CPU than it absolutely has to, so it'd effectively be turned off.

The JVM will instead reset it to its default value 5 and tell you as much as a log message.

Beyond 5, the CPU gets ever busier in exchange for using less and less memory beyond the live set, but expects starkly diminishing returns as the value grows.
The rest of this transcript — segmented and speaker-labeled, so you land on the exact moment something was said
Search every transcript — by keyword, by phrase, or by meaning, across every show Radar indexes
Trends — what is surging across podcasts, measured against its own baseline
Alerts — when a name you follow appears in a newly indexed episode
No account is needed to search Radar.