Package org.github.jamm
Enum Class MemoryMeter.Guess
- All Implemented Interfaces:
Serializable,Comparable<MemoryMeter.Guess>,Constable
- Enclosing class:
MemoryMeter
The different strategies that can be used by a
MemoryMeter instance to measure the shallow size of an object.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRelies onjava.lang.instrument.Instrumentationto measure shallow object size.Relies onjava.lang.instrument.Instrumentationto measure non array object and theSpecificationapproach to measure arrays.Computes the shallow size of objects using VM information.Relies onUnsafeto measure shallow object size. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic voidcheckOrder(List<MemoryMeter.Guess> guesses) booleanChecks if this strategy requiresInstrumentationto be present.booleanChecks if this strategy requiresUnsafeto be present.static MemoryMeter.GuessReturns the enum constant of this class with the specified name.static MemoryMeter.Guess[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTRUMENTATION
Relies onjava.lang.instrument.Instrumentationto measure shallow object size. It requiresInstrumentationto be available, but it is the most accurate strategy. -
INSTRUMENTATION_AND_SPECIFICATION
Relies onjava.lang.instrument.Instrumentationto measure non array object and theSpecificationapproach to measure arrays. This strategy tries to combine the best of both strategies the accuracy and speed ofInstrumentationfor non array object and the speed ofSpecificationfor measuring array objects for which all strategy are accurate. For some reasonInstrumentationis slower for arrays before Java 17. -
UNSAFE
Relies onUnsafeto measure shallow object size. It requiresUnsafeto be available. After INSTRUMENTATION based strategy UNSAFE is the most accurate strategy. -
SPECIFICATION
Computes the shallow size of objects using VM information.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
requireInstrumentation
public boolean requireInstrumentation()Checks if this strategy requiresInstrumentationto be present.- Returns:
trueif this strategy requiresInstrumentationto be present,falseotherwise.
-
requireUnsafe
public boolean requireUnsafe()Checks if this strategy requiresUnsafeto be present.- Returns:
trueif this strategy requiresUnsafeto be present,falseotherwise.
-
canBeUsedAsFallbackFrom
-
checkOrder
-