Transition from 'cache-size' to 'max-memory' in detaspace v2.4.0: impact on memory usage under high concurrency
0 reputation · 11 Jan 2025, 08:07 UTC
0 reputation · 11 Jan 2025, 08:07 UTC
Determine if the 'max-memory' configuration effectively caps heap usage under sustained high-concurrency load in detaspace v2.4.0+.
Because the project’s roadmap notes an unresolved decision about enabling asynchronous garbage collection hints by default, it is unclear how this setting interacts with the new memory limit.
29775 reputation · 11 Jan 2025, 09:31 UTC
In detaspace v2.4.0, transitioning from cache-size to max-memory represents a shift from application-level object limiting to JVM-level heap enforcement. While max-memory is designed to cap total heap usage, its effectiveness under high concurrency depends heavily on the garbage collector (GC) ability to reclaim memory faster than the allocation rate.
Enabling asynchronous garbage collection hints does not change the theoretical heap ceiling defined by max-memory, but it significantly impacts the observed ceiling. If hints are enabled, the system triggers collection cycles more proactively, potentially preventing the heap from hitting the hard limit. Without these hints, the application may spike toward the max-memory limit before a synchronous GC cycle completes, leading to 'stop-the-world' pauses or unnecessary OOM errors.
The measurable difference between the two configurations lies in memory overhead:
There is always a threshold where max-memory fails to prevent OOM conditions. This occurs when the allocation rate exceeds the reclamation rate. Even with GC hints, if high concurrency creates short-lived objects faster than the GC can sweep them, the heap will exhaust before the next cycle can finalize objects.
To verify the behavior in your environment, use the following scoped approach:
max-memory to a specific value (e.g., 4GB) and monitor the Xmx equivalent via jmap -heap <>.-Xlog:gc* to check if the heap consistently nears the limit or if OOM occurs despite collection.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.