Class MemoryEstimator

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

public class MemoryEstimator extends Object
Estimates memory usage of cache entries and maps. Uses both shallow and deep estimates for accuracy.
  • Constructor Details

    • MemoryEstimator

      public MemoryEstimator()
  • Method Details

    • estimateObjectSize

      public static long estimateObjectSize(Object obj)
      Estimate the size of a single object in bytes. Handles String, arrays, and generic objects.
    • estimateEntrySize

      public static long estimateEntrySize(Object key, Object value)
      Estimate total memory for a single map entry (key + value + overhead).
    • estimateMapSize

      public static long estimateMapSize(DistributedMap<?,?> map)
      Estimate total memory consumption of a DistributedMap.
    • estimateConcurrentHashMapSize

      public static <K,V> long estimateConcurrentHashMapSize(ConcurrentHashMap<K,V> map)
      Estimate memory for a ConcurrentHashMap.
    • estimateMapSize

      public static <K,V> long estimateMapSize(Map<K,V> map)
      Estimate memory for a generic Map.