Class MemoryEstimates


  • public class MemoryEstimates
    extends Object
    Memory Estimates is a helper class containing static classes that estimate the memory requirements of different types of objects in java. All estimates are worst case JVM x86-64bit uncompressed object pointers. This in practice means that the objects are most commonly smaller, for instance the object references are often time. If the memory pressure is low (there is a low number of allocated objects) then object pointers are 4 bits.
    • Constructor Detail

      • MemoryEstimates

        public MemoryEstimates()
    • Method Detail

      • bitSetCost

        public static long bitSetCost​(int length)
        Get the worst case memory usage of an java.util.BitSet java object.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • byteArrayCost

        public static long byteArrayCost​(int length)
        Get the worst case memory usage of an array of bytes.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • charArrayCost

        public static long charArrayCost​(int length)
        Get the worst case memory usage of an array of chars.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • intArrayCost

        public static double intArrayCost​(long length)
        Get the worst case memory usage of an array of integers.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • doubleArrayCost

        public static double doubleArrayCost​(long length)
        Get the worst case memory usage of an array of doubles.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • objectArrayCost

        public static double objectArrayCost​(long length)
        Get the worst case memory usage for an array of objects.
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes
      • longArrayCost

        public static double longArrayCost​(int length)
        Get the worst case memory usage for an array of longs
        Parameters:
        length - The length of the array.
        Returns:
        The memory estimate in bytes