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.Instrumentation
to measure shallow object size.Relies onjava.lang.instrument.Instrumentation
to measure non array object and theSpecification
approach to measure arrays.Computes the shallow size of objects using VM information.Relies onUnsafe
to measure shallow object size. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static void
checkOrder
(List<MemoryMeter.Guess> guesses) boolean
Checks if this strategy requiresInstrumentation
to be present.boolean
Checks if this strategy requiresUnsafe
to be present.static MemoryMeter.Guess
Returns 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.Instrumentation
to measure shallow object size. It requiresInstrumentation
to be available, but it is the most accurate strategy. -
INSTRUMENTATION_AND_SPECIFICATION
Relies onjava.lang.instrument.Instrumentation
to measure non array object and theSpecification
approach to measure arrays. This strategy tries to combine the best of both strategies the accuracy and speed ofInstrumentation
for non array object and the speed ofSpecification
for measuring array objects for which all strategy are accurate. For some reasonInstrumentation
is slower for arrays before Java 17. -
UNSAFE
Relies onUnsafe
to measure shallow object size. It requiresUnsafe
to 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 requiresInstrumentation
to be present.- Returns:
true
if this strategy requiresInstrumentation
to be present,false
otherwise.
-
requireUnsafe
public boolean requireUnsafe()Checks if this strategy requiresUnsafe
to be present.- Returns:
true
if this strategy requiresUnsafe
to be present,false
otherwise.
-
canBeUsedAsFallbackFrom
-
checkOrder
-