Package org.github.jamm.strategies
Class InstrumentationAndSpecStrategy
java.lang.Object
org.github.jamm.strategies.MemoryLayoutBasedStrategy
org.github.jamm.strategies.InstrumentationAndSpecStrategy
- All Implemented Interfaces:
MemoryMeterStrategy
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 -
Method Summary
Modifier and TypeMethodDescriptionlong
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
-
Constructor Details
-
InstrumentationAndSpecStrategy
-
-
Method Details
-
measureInstance
Description copied from class:MemoryLayoutBasedStrategy
Measures the shallow memory used by objects of the specified class.- Specified by:
measureInstance
in classMemoryLayoutBasedStrategy
- Parameters:
object
- the object to measuretype
- the object type- Returns:
- the shallow memory used by the object
-