Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.services.cache
Class ClassSize  view ClassSize download ClassSize.java

java.lang.Object
  extended byorg.apache.derby.iapi.services.cache.ClassSize

public class ClassSize
extends java.lang.Object


Field Summary
private static int booleanSize
           
private static java.util.Hashtable catalog
           
private static int charSize
           
private static int doubleSize
           
private static boolean dummyCatalog
           
private static int floatSize
           
private static int intSize
           
private static int longSize
           
private static int minObjectSize
           
(package private) static boolean noGuess
           
private static int objectOverhead
           
static int refSize
           
private static int shortSize
           
(package private) static boolean unitTest
           
private static int[] wildGuess
           
 
Constructor Summary
ClassSize()
           
 
Method Summary
static int estimateAndCatalogBase(java.lang.Class cls)
          Estimate the static space taken up by a class instance.
static int estimateArrayOverhead()
           
static int estimateBase(java.lang.Class cl)
          Estimate the static space taken up by the fields of a class.
static int estimateBaseFromCatalog(java.lang.Class cls)
          Estimate the static space taken up by a class instance from cataloged coefficients.
private static int estimateBaseFromCatalog(java.lang.Class cls, boolean addToCatalog)
           
static int estimateBaseFromCoefficients(int[] coeff)
          Estimate the static space taken up by a class instance given the coefficients returned by getSizeCoefficients.
static int estimateHashEntrySize()
          Estimate the size of a Hashtable entry.
static int estimateMemoryUsage(java.lang.String str)
          Estimate the size of a string.
static int getIntSize()
           
static int getRefSize()
          Get the estimate of the size of an object reference.
static int[] getSizeCoefficients(java.lang.Class cl)
          The estimate of the size of a class instance depends on whether the JVM uses 32 or 64 bit addresses, that is it depends on the size of an object reference.
static void setDummyCatalog()
          do not try to use the catalog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

refSize

public static final int refSize

objectOverhead

private static final int objectOverhead
See Also:
Constant Field Values

booleanSize

private static final int booleanSize
See Also:
Constant Field Values

charSize

private static final int charSize
See Also:
Constant Field Values

shortSize

private static final int shortSize
See Also:
Constant Field Values

intSize

private static final int intSize
See Also:
Constant Field Values

longSize

private static final int longSize
See Also:
Constant Field Values

floatSize

private static final int floatSize
See Also:
Constant Field Values

doubleSize

private static final int doubleSize
See Also:
Constant Field Values

minObjectSize

private static final int minObjectSize

dummyCatalog

private static boolean dummyCatalog

noGuess

static boolean noGuess

unitTest

static boolean unitTest

wildGuess

private static final int[] wildGuess

catalog

private static java.util.Hashtable catalog
Constructor Detail

ClassSize

public ClassSize()
Method Detail

setDummyCatalog

public static void setDummyCatalog()
do not try to use the catalog.


getRefSize

public static int getRefSize()
Get the estimate of the size of an object reference.


getIntSize

public static int getIntSize()

getSizeCoefficients

public static int[] getSizeCoefficients(java.lang.Class cl)
The estimate of the size of a class instance depends on whether the JVM uses 32 or 64 bit addresses, that is it depends on the size of an object reference. It is a linear function of the size of a reference, e.g. 24 + 5*r where r is the size of a reference (usually 4 or 8 bytes). This method returns the coefficients of the linear function, e.g. {24, 5} in the above example.


estimateBaseFromCoefficients

public static int estimateBaseFromCoefficients(int[] coeff)
Estimate the static space taken up by a class instance given the coefficients returned by getSizeCoefficients.


estimateBaseFromCatalog

public static int estimateBaseFromCatalog(java.lang.Class cls)
Estimate the static space taken up by a class instance from cataloged coefficients.


estimateBaseFromCatalog

private static int estimateBaseFromCatalog(java.lang.Class cls,
                                           boolean addToCatalog)

estimateAndCatalogBase

public static int estimateAndCatalogBase(java.lang.Class cls)
Estimate the static space taken up by a class instance. Save the coefficients in a catalog.


estimateBase

public static int estimateBase(java.lang.Class cl)
Estimate the static space taken up by the fields of a class. This includes the space taken up by by references (the pointer) but not by the referenced object. So the estimated size of an array field does not depend on the size of the array. Similarly the size of an object (reference) field does not depend on the object.


estimateArrayOverhead

public static int estimateArrayOverhead()

estimateHashEntrySize

public static int estimateHashEntrySize()
Estimate the size of a Hashtable entry. In Java 1.2 we can use Map.entry, but this is not available in earlier versions of Java.


estimateMemoryUsage

public static int estimateMemoryUsage(java.lang.String str)
Estimate the size of a string.