Class MemoryManager

java.lang.Object
com.loomcache.server.cache.MemoryManager

public class MemoryManager extends Object
Monitors JVM heap usage and cache memory consumption. Triggers eviction callbacks when soft/hard limits are reached.
  • Constructor Details

  • Method Details

    • withDefaultThresholds

      public static MemoryManager withDefaultThresholds()
      Create a MemoryManager with default thresholds (80%/90% of max heap).
    • getStats

      public MemoryManager.MemoryStats getStats(long cacheBytes)
      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

      public void registerEvictionCallback(Runnable callback)
      Register a callback to be invoked when soft limit is reached.
    • unregisterEvictionCallback

      public void unregisterEvictionCallback(Runnable callback)
      Unregister an eviction callback.
    • getSoftLimitBytes

      public long getSoftLimitBytes()
      Get soft limit threshold in bytes.
    • getHardLimitBytes

      public long getHardLimitBytes()
      Get hard limit threshold in bytes.