|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.Base
com.tangosol.net.cache.SimpleMemoryCalculator
public class SimpleMemoryCalculator
A UnitCalculator implementation that weighs a cache entry based upon the amount of physical memory (in bytes) required to store the entry.
This implementation can only determine an accurate entry size if both the entry key and value object types are one of the following classes (or an array thereof):Binary
Field Summary | |
---|---|
static Map |
MAP_FIXED_SIZES
An immutable map of fixed-sized classes to instance size (in bytes). |
static int |
SIZE_BINARY
The minimum size (in bytes) of a Binary object. |
static int |
SIZE_BOOLEAN
The size (in bytes) of a Boolean object. |
static int |
SIZE_BYTE
The size (in bytes) of a Byte object. |
static int |
SIZE_CHARACTER
The size (in bytes) of a Character object. |
static int |
SIZE_DOUBLE
The size (in bytes) of a Double object. |
static int |
SIZE_ENTRY
The minimum size (in bytes) of an LocalCache.Entry object. |
static int |
SIZE_FLOAT
The size (in bytes) of a Float object. |
static int |
SIZE_INTEGER
The size (in bytes) of a Integer object. |
static int |
SIZE_LONG
The size (in bytes) of a Long object. |
static int |
SIZE_OBJECT
The size (in bytes) of an Object . |
static int |
SIZE_OBJECT_REF
The size (in bytes) of an object reference. |
static int |
SIZE_SHORT
The size (in bytes) of a Short object. |
static int |
SIZE_STRING
The minimum size (in bytes) of a String object. |
Constructor Summary | |
---|---|
SimpleMemoryCalculator()
|
Method Summary | |
---|---|
protected static int |
calculateShallowSize(Class clz)
Calculate the approximate number of bytes required to store an instance of the given class and its non-static fields in memory. |
int |
calculateUnits(Object oKey,
Object oValue)
Calculate a cache cost for the specified cache entry key and value. |
static void |
main(String[] asArg)
Unit test. |
protected int |
padMemorySize(int cb)
Round the given number of bytes to the next closest integer that is divisible by 8. |
protected int |
sizeOf(Class clz)
Determine the minimum number of bytes required to store an instance of the given fixed-sized class in memory. |
protected int |
sizeOf(Object o)
Estimate the number of bytes of memory consumed by the given object. |
Field Detail |
---|
public static final int SIZE_OBJECT_REF
public static final int SIZE_OBJECT
Object
.
public static final int SIZE_BOOLEAN
Boolean
object.
public static final int SIZE_BYTE
Byte
object.
public static final int SIZE_SHORT
Short
object.
public static final int SIZE_CHARACTER
Character
object.
public static final int SIZE_INTEGER
Integer
object.
public static final int SIZE_FLOAT
Float
object.
public static final int SIZE_LONG
Long
object.
public static final int SIZE_DOUBLE
Double
object.
public static final int SIZE_STRING
String
object.
public static final int SIZE_BINARY
Binary
object.
public static final int SIZE_ENTRY
LocalCache.Entry
object.
public static final Map MAP_FIXED_SIZES
Constructor Detail |
---|
public SimpleMemoryCalculator()
Method Detail |
---|
public int calculateUnits(Object oKey, Object oValue)
calculateUnits
in interface OldCache.UnitCalculator
oKey
- the cache key to evaluate for unit costoValue
- the cache value to evaluate for unit cost
protected int sizeOf(Object o)
Class Size boolean 1 byte 1 short 2 char 2 int 4 float 4 long 8 double 8 Object SIZE_OBJECT
Boolean SIZE_OBJECT
+ 1Byte SIZE_OBJECT
+ 1Short SIZE_OBJECT
+ 2Character SIZE_OBJECT
+ 2Integer SIZE_OBJECT
+ 4Float SIZE_OBJECT
+ 4Long SIZE_OBJECT
+ 8Double SIZE_OBJECT
+ 8String SIZE_STRING
+ 2*length()Binary SIZE_BINARY
+ length()isArray() 16 + [element size]*length()
o
- the object to measure the size of
IllegalArgumentException
- if the type of the object is not one of
the classes listed aboveprotected int sizeOf(Class clz)
Class Size boolean 1 byte 1 short 2 char 2 int 4 float 4 long 8 double 8 Object SIZE_OBJECT
Boolean SIZE_OBJECT
+ 1Byte SIZE_OBJECT
+ 1Short SIZE_OBJECT
+ 2Character SIZE_OBJECT
+ 2Integer SIZE_OBJECT
+ 4Float SIZE_OBJECT
+ 4Long SIZE_OBJECT
+ 8Double SIZE_OBJECT
+ 8
clz
- the target class
IllegalArgumentException
- if the type of the object is not one of
the classes listed aboveprotected int padMemorySize(int cb)
cb
- the number of bytes to round
protected static int calculateShallowSize(Class clz)
clz
- the target class
public static void main(String[] asArg)
java com.tangosol.net.cache.SimpleMemoryCalculator [class name]
asArg
- command line arguments
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |