public final class

RamUsageEstimator

extends Object
java.lang.Object
   ↳ org.apache.lucene.util.RamUsageEstimator

Class Overview

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.

Summary

Public Constructors
RamUsageEstimator()
Constructs this object with an AverageGuessMemoryModel and checkInterned = true.
RamUsageEstimator(boolean checkInterned)
RamUsageEstimator(MemoryModel memoryModel)
RamUsageEstimator(MemoryModel memoryModel, boolean checkInterned)
Public Methods
long estimateRamUsage(Object obj)
static String humanReadableUnits(long bytes, DecimalFormat df)
Return good default units based on byte size.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public RamUsageEstimator ()

Constructs this object with an AverageGuessMemoryModel and checkInterned = true.

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.

public RamUsageEstimator (MemoryModel memoryModel)

Parameters
memoryModel MemoryModel to use for primitive object sizes.

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.

Public Methods

public long estimateRamUsage (Object obj)

public static String humanReadableUnits (long bytes, DecimalFormat df)

Return good default units based on byte size.