Enum Class MemoryMeter.Guess

java.lang.Object
java.lang.Enum<MemoryMeter.Guess>
org.github.jamm.MemoryMeter.Guess
All Implemented Interfaces:
Serializable, Comparable<MemoryMeter.Guess>, Constable
Enclosing class:
MemoryMeter

public static enum MemoryMeter.Guess extends Enum<MemoryMeter.Guess>
The different strategies that can be used by a MemoryMeter instance to measure the shallow size of an object.
  • Enum Constant Details

    • INSTRUMENTATION

      public static final MemoryMeter.Guess INSTRUMENTATION
      Relies on java.lang.instrument.Instrumentation to measure shallow object size. It requires Instrumentation to be available, but it is the most accurate strategy.
    • INSTRUMENTATION_AND_SPECIFICATION

      public static final MemoryMeter.Guess INSTRUMENTATION_AND_SPECIFICATION
      Relies on java.lang.instrument.Instrumentation to measure non array object and the Specification approach to measure arrays. This strategy tries to combine the best of both strategies the accuracy and speed of Instrumentation for non array object and the speed of Specification for measuring array objects for which all strategy are accurate. For some reason Instrumentation is slower for arrays before Java 17.
    • UNSAFE

      public static final MemoryMeter.Guess UNSAFE
      Relies on Unsafe to measure shallow object size. It requires Unsafe to be available. After INSTRUMENTATION based strategy UNSAFE is the most accurate strategy.
    • SPECIFICATION

      public static final MemoryMeter.Guess SPECIFICATION
      Computes the shallow size of objects using VM information.
  • Method Details

    • values

      public static MemoryMeter.Guess[] 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

      public static MemoryMeter.Guess valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • requireInstrumentation

      public boolean requireInstrumentation()
      Checks if this strategy requires Instrumentation to be present.
      Returns:
      true if this strategy requires Instrumentation to be present, false otherwise.
    • requireUnsafe

      public boolean requireUnsafe()
      Checks if this strategy requires Unsafe to be present.
      Returns:
      true if this strategy requires Unsafe to be present, false otherwise.
    • canBeUsedAsFallbackFrom

      public boolean canBeUsedAsFallbackFrom(MemoryMeter.Guess guess)
    • checkOrder

      public static void checkOrder(List<MemoryMeter.Guess> guesses)