org.apache.lucene.util

## Class RamUsageTester

- java.lang.Object
- - org.apache.lucene.util.RamUsageTester

-     public final class RamUsageTester
      extends Object

  Crawls object graph to collect RAM usage for testing

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RamUsageTester.Accumulator` An accumulator of object references.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RamUsageTester()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `humanSizeOf(Object object)` Return a human-readable size of a given object.
    `static long` | `sizeOf(Object obj)` Same as calling `sizeOf(obj, DEFAULT_FILTER)`.
    `static long` | `sizeOf(Object obj, RamUsageTester.Accumulator accumulator)` Estimates the RAM usage by the given object.

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

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

- - ### Constructor Detail

    - #### RamUsageTester

          public RamUsageTester()

  - ### Method Detail

    - #### sizeOf

          public static long sizeOf(Object obj,
                                    RamUsageTester.Accumulator accumulator)

      Estimates the RAM usage by the given object. It will walk the object tree and sum up all referenced objects.

      Resource Usage: This method internally uses a set of every object seen during traversals so it does allocate memory (it isn't side-effect free). After the method exits, this memory should be GCed.

    - #### sizeOf

          public static long sizeOf(Object obj)

      Same as calling `sizeOf(obj, DEFAULT_FILTER)`.

    - #### humanSizeOf

          public static String humanSizeOf(Object object)

      Return a human-readable size of a given object.
      See Also:
        `sizeOf(Object)`, `RamUsageEstimator.humanReadableUnits(long)`

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.