Package org.apache.sysds.utils
Class MemoryEstimates
java.lang.Object
org.apache.sysds.utils.MemoryEstimates
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic doublebitSetCost(long length) Get the worst case memory usage of an java.util.BitSet java object.static doublebooleanArrayCost(long length) Get the worst case memory usage of an array of booleans.static doublebyteArrayCost(long length) Get the worst case memory usage of an array of bytes.static doublecharArrayCost(long length) Get the worst case memory usage of an array of chars.static final doubledoubleArrayCost(long length) Get the worst case memory usage of an array of doubles.static doublefloatArrayCost(long length) Get the worst case memory usage of an array of integers.static doubleintArrayCost(long length) Get the worst case memory usage of an array of integers.static final doublelongArrayCost(long length) Get the worst case memory usage for an array of longsstatic final doubleobjectArrayCost(long length) Get the worst case memory usage for an array of objects.static final doublestringArrayCost(int length, int avgStringLength) static final doublestringArrayCost(String[] strings) Get the worst case memory usage of an array containing strings.static longstringCost(long length) Get the worst case memory usage of a single string, assuming given length.static longstringCost(String value) Get the worst case memory usage of a single string.
-
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
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
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
-