Interface MemoryPressureController
- All Known Implementing Classes:
MemoryPressureController.JvmMemoryPressureController
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Determines whether caches should proactively shed entries.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMinimum occupied percentage of a cache's configured weight budget before sustained GC time alone may trigger trimming.static final StringGC-time percentage over the sampling window that triggers JVM-wide memory-aware cache trimming.static final StringPost-GC heap usage percentage that triggers JVM-wide memory-aware cache trimming.static final StringMaximum cache weight to evict per observed memory-pressure pass.static final StringPercentage of the registered memory-aware cache weight to evict per observed memory-pressure pass.static final MemoryPressureController -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryPressureControllerjvm()Creates a controller using JVM memory pressure and the default property source.static MemoryPressureControllerjvm(PropertySource propertySource) Creates a JVM memory-pressure controller configured through the supplied property source.default longReturns the maximum cache weight to remove in one pressure-driven trim.static MemoryPressureControllernone()Returns a controller that never requests memory-pressure eviction.booleanshouldEvict(long currentWeight, long maxWeight) Returns whether memory pressure warrants eviction given the current cache weight and configured maximum weight.default intReturns the percentage of cache weight targeted by a pressure-driven trim.
-
Field Details
-
MEMORY_PRESSURE_HEAP_THRESHOLD_PERCENT_PROPERTY
Post-GC heap usage percentage that triggers JVM-wide memory-aware cache trimming. Defaults to85. Measuring retained occupancy instead of instantaneous Eden usage prevents a normal allocation burst just before a young collection from evicting hot cache entries.- See Also:
-
MEMORY_PRESSURE_GC_TIME_THRESHOLD_PERCENT_PROPERTY
GC-time percentage over the sampling window that triggers JVM-wide memory-aware cache trimming. Defaults to20. GC pressure is evaluated over a sustained window so a single short collection does not evict hot cache entries while heap usage remains healthy.- See Also:
-
MEMORY_PRESSURE_GC_CACHE_UTILIZATION_PERCENT_PROPERTY
Minimum occupied percentage of a cache's configured weight budget before sustained GC time alone may trigger trimming. Defaults to50. Actual post-GC heap pressure remains sufficient by itself.- See Also:
-
MEMORY_PRESSURE_TRIM_RATIO_PERCENT_PROPERTY
Percentage of the registered memory-aware cache weight to evict per observed memory-pressure pass. Defaults to20.- See Also:
-
MEMORY_PRESSURE_MAX_TRIM_WEIGHT_PROPERTY
Maximum cache weight to evict per observed memory-pressure pass. For byte-weighted caches this is bytes; for count-weighted caches this is entries. Defaults to1 GiB.- See Also:
-
NONE
-
-
Method Details
-
shouldEvict
boolean shouldEvict(long currentWeight, long maxWeight) Returns whether memory pressure warrants eviction given the current cache weight and configured maximum weight. -
trimRatioPercent
default int trimRatioPercent()Returns the percentage of cache weight targeted by a pressure-driven trim. -
maxTrimWeight
default long maxTrimWeight()Returns the maximum cache weight to remove in one pressure-driven trim. -
none
Returns a controller that never requests memory-pressure eviction. -
jvm
Creates a controller using JVM memory pressure and the default property source. -
jvm
Creates a JVM memory-pressure controller configured through the supplied property source.
-