Package org.github.jamm.strategies

# 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.

## Field Summary

### Fields inherited from interface org.github.jamm.MemoryMeterStrategy

`MEMORY_LAYOUT`

## Constructor Summary

Constructors
Constructor
Description
`InstrumentationAndSpecStrategy(Instrumentation instrumentation)`

## Method Summary

Modifier and Type
Method
Description
`long`
`measureInstance(Object object, Class<?> type)`
Measures the shallow memory used by objects of the specified class.

### Methods inherited from class org.github.jamm.strategies.MemoryLayoutBasedStrategy

`arrayBaseOffset, computeArraySize, measure, measureArray, measureArray, measureArray, measureArray, measureArray, measureArray, measureArray, measureArray, measureArray, measureArray, measureField, supportComputeArraySize`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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