Class MemoryMeter.Builder

java.lang.Object
org.github.jamm.MemoryMeter.Builder
Enclosing class:
MemoryMeter

public static final class MemoryMeter.Builder extends Object
Builder for MemoryMeter instances
  • Method Details

    • build

      public MemoryMeter build()
    • withGuessing

      public MemoryMeter.Builder withGuessing(MemoryMeter.Guess strategy, MemoryMeter.Guess... fallbacks)
      Specify what should be the strategy used to measure the shallow size of object.
      Parameters:
      strategy - the strategy that should be used to measure objects
      fallbacks - the fallback strategies
      Returns:
      this builder
    • ignoreOuterClassReference

      public MemoryMeter.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

      public MemoryMeter.Builder measureKnownSingletons()
      Measures the space occupied by known singletons such as Class objects, enums, ClassLoaders and AccessControlContexts. By default MemoryMeter will ignore those.
      Returns:
      this builder
    • measureNonStrongReferences

      public MemoryMeter.Builder measureNonStrongReferences()
      Measures the references from a Reference (like weak/soft/phantom references). By default MemoryMeter will ignore those.
      Returns:
      this builder
    • printVisitedTree

      public MemoryMeter.Builder printVisitedTree()
      Prints the classes tree to System.out when measuring through measureDeep.
      Returns:
      this builder
    • printVisitedTreeUpTo

      public MemoryMeter.Builder printVisitedTreeUpTo(int depth)
      Prints the classes tree to System.out up to the specified depth when measuring through measureDeep.
      Parameters:
      depth - the depth up to which the class tree must be printed
      Returns:
      this builder