org.apache.lucene.util

## Class RamUsageEstimator

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

-     public final class RamUsageEstimator
      extends java.lang.Object

  Estimates the size of a given Object using a given MemoryModel for primitive size information. Resource Usage: Internally uses a Map to temporally hold a reference to every object seen. If checkIntered, all Strings checked will be interned, but those that were not already interned will be released for GC when the estimate is complete.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RamUsageEstimator()` Constructs this object with an AverageGuessMemoryModel and checkInterned = true.
    `RamUsageEstimator(boolean checkInterned)`
    `RamUsageEstimator(MemoryModel memoryModel)`
    `RamUsageEstimator(MemoryModel memoryModel, boolean checkInterned)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `estimateRamUsage(java.lang.Object obj)`
    `static java.lang.String` | `humanReadableUnits(long bytes, java.text.DecimalFormat df)` Return good default units based on byte size.

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

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

- - ### Constructor Detail

    - #### RamUsageEstimator

          public RamUsageEstimator()

      Constructs this object with an AverageGuessMemoryModel and checkInterned = true.

    - #### RamUsageEstimator

          public RamUsageEstimator(boolean checkInterned)

      Parameters:
        `checkInterned` - check if Strings are interned and don't add to size if they are. Defaults to true but if you know the objects you are checking won't likely contain many interned Strings, it will be faster to turn off intern checking.

    - #### RamUsageEstimator

          public RamUsageEstimator(MemoryModel memoryModel)

      Parameters:
        `memoryModel` - MemoryModel to use for primitive object sizes.

    - #### RamUsageEstimator

          public RamUsageEstimator(MemoryModel memoryModel,
                                   boolean checkInterned)

      Parameters:
        `memoryModel` - MemoryModel to use for primitive object sizes.
        `checkInterned` - check if Strings are interned and don't add to size if they are. Defaults to true but if you know the objects you are checking won't likely contain many interned Strings, it will be faster to turn off intern checking.

  - ### Method Detail

    - #### estimateRamUsage

          public long estimateRamUsage(java.lang.Object obj)

    - #### humanReadableUnits

          public static java.lang.String humanReadableUnits(long bytes,
                                                            java.text.DecimalFormat df)

      Return good default units based on byte size.

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