Package org.github.jamm
Class MemoryMeter.Builder
java.lang.Object
org.github.jamm.MemoryMeter.Builder
- Enclosing class:
- MemoryMeter
Builder for
MemoryMeter
instances-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Ignores the outer class reference from non-static inner classes.Measures the space occupied by known singletons such asClass
objects,enum
s,ClassLoader
s andAccessControlContext
s.Measures the references from aReference
(like weak/soft/phantom references).Prints the classes tree toSystem.out
when measuring throughmeasureDeep
.printVisitedTreeUpTo
(int depth) Prints the classes tree toSystem.out
up to the specified depth when measuring throughmeasureDeep
.withGuessing
(MemoryMeter.Guess strategy, MemoryMeter.Guess... fallbacks) Specify what should be the strategy used to measure the shallow size of object.
-
Method Details
-
build
-
withGuessing
Specify what should be the strategy used to measure the shallow size of object.- Parameters:
strategy
- the strategy that should be used to measure objectsfallbacks
- the fallback strategies- Returns:
- this builder
-
ignoreOuterClassReference
Ignores the outer class reference from non-static inner classes.In practice this is only useful if the top class provided to
MemoryMeter.measureDeep
is an inner class and we wish to ignore the outer class in the measurement.- Returns:
- this builder
-
measureKnownSingletons
Measures the space occupied by known singletons such asClass
objects,enum
s,ClassLoader
s andAccessControlContext
s. By defaultMemoryMeter
will ignore those.- Returns:
- this builder
-
measureNonStrongReferences
Measures the references from aReference
(like weak/soft/phantom references). By defaultMemoryMeter
will ignore those.- Returns:
- this builder
-
printVisitedTree
Prints the classes tree toSystem.out
when measuring throughmeasureDeep
.- Returns:
- this builder
-
printVisitedTreeUpTo
Prints the classes tree toSystem.out
up to the specified depth when measuring throughmeasureDeep
.- Parameters:
depth
- the depth up to which the class tree must be printed- Returns:
- this builder
-