org.apache.lucene.util
Class RamUsageEstimator

java.lang.Object
  extended by org.apache.lucene.util.RamUsageEstimator

public final class RamUsageEstimator
extends 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
RamUsageEstimator()
          Constructs this object with an AverageGuessMemoryModel and checkInterned = true.
RamUsageEstimator(boolean checkInterned)
           
RamUsageEstimator(MemoryModel memoryModel)
           
RamUsageEstimator(MemoryModel memoryModel, boolean checkInterned)
           
 
Method Summary
 long estimateRamUsage(Object obj)
           
static String humanReadableUnits(long bytes, 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(Object obj)

humanReadableUnits

public static String humanReadableUnits(long bytes,
                                        DecimalFormat df)
Return good default units based on byte size.



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