Package org.github.jamm
Interface MemoryMeterStrategy
- All Known Implementing Classes:
InstrumentationAndSpecStrategy,MemoryLayoutBasedStrategy,UnsafeStrategy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a strategy to measure the shallow memory used by a Java object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MemoryLayoutSpecificationThe memory layout detected by JAMM. -
Method Summary
Modifier and TypeMethodDescriptiondefault longcomputeArraySize(int length, int elementSize) Computes an array size from its length and element size (optional operation).longMeasures the shallow memory used by the specified object.default longmeasureArray(boolean[] array) Measures the shallow memory used by the specified boolean array.default longmeasureArray(byte[] array) Measures the shallow memory used by the specified byte array.default longmeasureArray(char[] array) Measures the shallow memory used by the specified char array.default longmeasureArray(double[] array) Measures the shallow memory used by the specified double array.default longmeasureArray(float[] array) Measures the shallow memory used by the specified float array.default longmeasureArray(int[] array) Measures the shallow memory used by the specified int array.default longmeasureArray(long[] array) Measures the shallow memory used by the specified long array.default longmeasureArray(short[] array) Measures the shallow memory used by the specified short array.default longmeasureArray(Object[] array) Measures the shallow memory used by the specified array.default longmeasureArray(Object array, Class<?> type) Measures the shallow memory used by the specified array.default booleanChecks if this instance supports thecomputeArraySizeoperation.
-
Field Details
-
MEMORY_LAYOUT
The memory layout detected by JAMM.
-
-
Method Details
-
measure
Measures the shallow memory used by the specified object.- Parameters:
object- the object to measure- Returns:
- the shallow memory usage of the specified object
-
measureArray
Measures the shallow memory used by the specified array.- Parameters:
array- the array to measuretype- the array type- Returns:
- the shallow memory usage of the specified array
-
measureArray
Measures the shallow memory used by the specified array.- Parameters:
array- the array to measure- Returns:
- the shallow memory used by the specified array.
-
measureArray
default long measureArray(byte[] array) Measures the shallow memory used by the specified byte array.- Parameters:
array- the array to measure- Returns:
- the shallow memory used by the specified byte array.
-
measureArray
default long measureArray(boolean[] array) Measures the shallow memory used by the specified boolean array.- Parameters:
array- the boolean array to measure- Returns:
- the shallow memory used by the specified boolean array.
-
measureArray
default long measureArray(short[] array) Measures the shallow memory used by the specified short array.- Parameters:
array- the short array to measure- Returns:
- the shallow memory used by the specified short array.
-
measureArray
default long measureArray(char[] array) Measures the shallow memory used by the specified char array.- Parameters:
array- the char array to measure- Returns:
- the shallow memory used by the specified char array.
-
measureArray
default long measureArray(int[] array) Measures the shallow memory used by the specified int array.- Parameters:
array- the int array to measure- Returns:
- the shallow memory used by the specified int array.
-
measureArray
default long measureArray(float[] array) Measures the shallow memory used by the specified float array.- Parameters:
array- the float array to measure- Returns:
- the shallow memory used by the specified float array.
-
measureArray
default long measureArray(long[] array) Measures the shallow memory used by the specified long array.- Parameters:
array- the long array to measure- Returns:
- the shallow memory used by the specified long array.
-
measureArray
default long measureArray(double[] array) Measures the shallow memory used by the specified double array.- Parameters:
array- the long array to measure- Returns:
- the shallow memory used by the specified double array.
-
supportComputeArraySize
default boolean supportComputeArraySize()Checks if this instance supports thecomputeArraySizeoperation.- Returns:
trueif this instance support thecomputeArraySizeoperation,falseotherwise.
-
computeArraySize
default long computeArraySize(int length, int elementSize) Computes an array size from its length and element size (optional operation).supportComputeArraySizeshould be used before calling this method to check if this operation is supported.- Parameters:
length- the array lengthelementSize- the size of the elements- Returns:
- the array size
- Throws:
UnsupportedOperationException- if the operation is not supported
-