Class MemoryManager
java.lang.Object
com.loomcache.server.cache.MemoryManager
Monitors JVM heap usage and cache memory consumption.
Triggers eviction callbacks when soft/hard limits are reached.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMemory usage statistics.static final recordMemory threshold configuration. softLimit: 80% of heap — triggers background eviction hardLimit: 90% of heap — rejects new writes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckHardLimit(long cacheBytes) Check if memory is above hard limit.booleancheckSoftLimit(long cacheBytes) Check if memory is above soft limit.longGet hard limit threshold in bytes.longGet soft limit threshold in bytes.getStats(long cacheBytes) Get current memory statistics from the JVM.voidregisterEvictionCallback(Runnable callback) Register a callback to be invoked when soft limit is reached.voidunregisterEvictionCallback(Runnable callback) Unregister an eviction callback.static MemoryManagerCreate a MemoryManager with default thresholds (80%/90% of max heap).
-
Constructor Details
-
MemoryManager
-
-
Method Details
-
withDefaultThresholds
Create a MemoryManager with default thresholds (80%/90% of max heap). -
getStats
Get current memory statistics from the JVM. -
checkSoftLimit
public boolean checkSoftLimit(long cacheBytes) Check if memory is above soft limit. If so, trigger eviction callbacks. -
checkHardLimit
public boolean checkHardLimit(long cacheBytes) Check if memory is above hard limit. -
registerEvictionCallback
Register a callback to be invoked when soft limit is reached. -
unregisterEvictionCallback
Unregister an eviction callback. -
getSoftLimitBytes
public long getSoftLimitBytes()Get soft limit threshold in bytes. -
getHardLimitBytes
public long getHardLimitBytes()Get hard limit threshold in bytes.
-