Class MemoryEstimates

java.lang.Object
org.apache.sysds.utils.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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    bitSetCost(long length)
    Get the worst case memory usage of an java.util.BitSet java object.
    static double
    booleanArrayCost(long length)
    Get the worst case memory usage of an array of booleans.
    static double
    byteArrayCost(long length)
    Get the worst case memory usage of an array of bytes.
    static double
    charArrayCost(long length)
    Get the worst case memory usage of an array of chars.
    static final double
    doubleArrayCost(long length)
    Get the worst case memory usage of an array of doubles.
    static double
    floatArrayCost(long length)
    Get the worst case memory usage of an array of integers.
    static double
    intArrayCost(long length)
    Get the worst case memory usage of an array of integers.
    static final double
    longArrayCost(long length)
    Get the worst case memory usage for an array of longs
    static final double
    objectArrayCost(long length)
    Get the worst case memory usage for an array of objects.
    static final double
    stringArrayCost(int length, int avgStringLength)
     
    static final double
    Get the worst case memory usage of an array containing strings.
    static long
    stringCost(long length)
    Get the worst case memory usage of a single string, assuming given length.
    static long
    Get the worst case memory usage of a single string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MemoryEstimates

      public MemoryEstimates()
  • Method Details

    • bitSetCost

      public static double bitSetCost(long 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
    • booleanArrayCost

      public static double booleanArrayCost(long length)
      Get the worst case memory usage of an array of booleans. Unfortunately in java booleans are allocated as bytes.
      Parameters:
      length - The length of the array.
      Returns:
      The memory estimate in bytes.
    • byteArrayCost

      public static double byteArrayCost(long 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 double charArrayCost(long 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
    • floatArrayCost

      public static double floatArrayCost(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 final 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 final double objectArrayCost(long length)
      Get the worst case memory usage for an array of objects. Note this does not take into account each objects allocated variables, just the objects themselves.
      Parameters:
      length - The length of the array.
      Returns:
      The memory estimate in bytes
    • longArrayCost

      public static final double longArrayCost(long 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
    • stringArrayCost

      public static final double stringArrayCost(String[] strings)
      Get the worst case memory usage of an array containing strings. In case anyone is wondering ... strings are expensive.
      Parameters:
      strings - The strings array.
      Returns:
      The array memory cost
    • stringArrayCost

      public static final double stringArrayCost(int length, int avgStringLength)
    • stringCost

      public static long stringCost(String value)
      Get the worst case memory usage of a single string. In case anyone is wondering ... strings are expensive.
      Parameters:
      value - The String to measure
      Returns:
      The size in memory.
    • stringCost

      public static long stringCost(long length)
      Get the worst case memory usage of a single string, assuming given length.
      Parameters:
      length - The length of the string
      Returns:
      The size in memory