public abstract class MemoryLayoutBasedStrategy extends Object implements MemoryMeterStrategy
MemoryLayoutSpecification for computing object size.MEMORY_LAYOUT| Constructor and Description |
|---|
MemoryLayoutBasedStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
arrayBaseOffset()
Returns the array base offset.
|
long |
computeArraySize(int length,
int elementSize)
Computes the size of an array from its length and elementSize.
|
long |
measure(Object object)
Measures the shallow memory used by the specified object.
|
long |
measureArray(boolean[] array)
Measures the shallow memory used by the specified boolean array.
|
long |
measureArray(byte[] array)
Measures the shallow memory used by the specified byte array.
|
long |
measureArray(char[] array)
Measures the shallow memory used by the specified char array.
|
long |
measureArray(double[] array)
Measures the shallow memory used by the specified double array.
|
long |
measureArray(float[] array)
Measures the shallow memory used by the specified float array.
|
long |
measureArray(int[] array)
Measures the shallow memory used by the specified int array.
|
long |
measureArray(long[] array)
Measures the shallow memory used by the specified long array.
|
long |
measureArray(Object[] array)
Measures the shallow memory used by the specified array.
|
long |
measureArray(Object instance,
Class<?> type)
Measure the shallow memory used by the specified array.
|
long |
measureArray(short[] array)
Measures the shallow memory used by the specified short array.
|
protected int |
measureField(Class<?> type)
Returns the size of a field of the specified type.
|
protected abstract long |
measureInstance(Object instance,
Class<?> type)
Measures the shallow memory used by objects of the specified class.
|
boolean |
supportComputeArraySize()
Checks if this instance supports the
computeArraySize operation. |
public final long measure(Object object)
MemoryMeterStrategymeasure in interface MemoryMeterStrategyobject - the object to measurepublic long measureArray(Object[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the array to measurepublic long measureArray(byte[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the array to measurepublic long measureArray(boolean[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the boolean array to measurepublic long measureArray(short[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the short array to measurepublic long measureArray(char[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the char array to measurepublic long measureArray(int[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the int array to measurepublic long measureArray(float[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the float array to measurepublic long measureArray(long[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the long array to measurepublic long measureArray(double[] array)
MemoryMeterStrategymeasureArray in interface MemoryMeterStrategyarray - the long array to measureprotected abstract long measureInstance(Object instance, Class<?> type)
instance - the object to measuretype - the object typepublic final long measureArray(Object instance, Class<?> type)
measureArray in interface MemoryMeterStrategyinstance - the array instancetype - the array typepublic boolean supportComputeArraySize()
MemoryMeterStrategycomputeArraySize operation.supportComputeArraySize in interface MemoryMeterStrategytrue if this instance support the computeArraySize operation, false otherwise.protected int arrayBaseOffset()
Array base is aligned based on heap word. It is not visible by default as compressed references are used and the header size is 16 but becomes visible when they are disabled.
public long computeArraySize(int length,
int elementSize)
computeArraySize in interface MemoryMeterStrategylength - the array lengthelementSize - the size of the array elementsprotected final int measureField(Class<?> type)
type - the field typeCopyright © 2023. All rights reserved.