Class InstrumentationAndSpecStrategy

java.lang.Object
org.github.jamm.strategies.MemoryLayoutBasedStrategy
org.github.jamm.strategies.InstrumentationAndSpecStrategy
All Implemented Interfaces:
MemoryMeterStrategy

public class InstrumentationAndSpecStrategy extends MemoryLayoutBasedStrategy
Strategy that use 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.
  • Constructor Details

    • InstrumentationAndSpecStrategy

      public InstrumentationAndSpecStrategy(Instrumentation instrumentation)
  • Method Details

    • measureInstance

      public long measureInstance(Object object, Class<?> type)
      Description copied from class: MemoryLayoutBasedStrategy
      Measures the shallow memory used by objects of the specified class.
      Specified by:
      measureInstance in class MemoryLayoutBasedStrategy
      Parameters:
      object - the object to measure
      type - the object type
      Returns:
      the shallow memory used by the object