|
Oracle® Coherence Java API Reference v3.5 E14977-01 |
|||||||
| 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 or of the primitive forms thereof):Binary
| Field Summary | |
|---|---|
static java.util.Map |
MAP_FIXED_SIZES
An immutable map of fixed-sized classes to instance size (in bytes). |
protected static int |
SIZE_BASIC_OBJECT
The unalligned size of the simplest object. |
static int |
SIZE_BIGDECIMAL
The size (in bytes) of a BigDecimal object. |
static int |
SIZE_BIGINTEGER
The size (in bytes) of a BigInteger object. |
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_DATE
The size (in bytes) of a Date, Date
or Time 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. |
static int |
SIZE_TIMESTAMP
The size (in bytes) of a Timestamp object. |
| Constructor Summary | |
|---|---|
SimpleMemoryCalculator()
|
|
| Method Summary | |
|---|---|
protected static int |
calculateShallowSize(java.lang.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(java.lang.Object oKey,
java.lang.Object oValue)
Calculate a cache cost for the specified cache entry key and value. |
java.lang.String |
getName()
Obtain the name of the unit calculator. |
static void |
main(java.lang.String[] asArg)
Unit test. |
protected static int |
padMemorySize(int cb)
Round the given number of bytes to the next closest integer that is divisible by 16. |
protected int |
sizeOf(java.lang.Class clz)
Determine the minimum number of bytes required to store an instance of the given fixed-sized class in memory. |
protected int |
sizeOf(java.lang.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_DATE
Date, Date
or Time object.
public static final int SIZE_TIMESTAMP
Timestamp object.
public static final int SIZE_BIGINTEGER
BigInteger object.
public static final int SIZE_BIGDECIMAL
BigDecimal 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 java.util.Map MAP_FIXED_SIZES
protected static final int SIZE_BASIC_OBJECT
| Constructor Detail |
|---|
public SimpleMemoryCalculator()
| Method Detail |
|---|
public int calculateUnits(java.lang.Object oKey,
java.lang.Object oValue)
calculateUnits in interface ConfigurableCacheMap.UnitCalculatoroKey - the cache key to evaluate for unit costoValue - the cache value to evaluate for unit cost
public java.lang.String getName()
getName in interface ConfigurableCacheMap.UnitCalculatorprotected int sizeOf(java.lang.Object o)
Class Size boolean 1 byte 1 short 2 char 2 int 4 long 8 float 4 double 8 Object SIZE_OBJECTBoolean SIZE_OBJECT+ 1Byte SIZE_OBJECT+ 1Short SIZE_OBJECT+ 2Character SIZE_OBJECT+ 2Integer SIZE_OBJECT+ 4Long SIZE_OBJECT+ 8Float SIZE_OBJECT+ 4Double SIZE_OBJECT+ 8BigInteger SIZE_OBJECT+ 48BigDecimal SIZE_OBJECT+ 4 +SIZE_OBJECT_REF+SIZE_BIGINTEGERDate SIZE_OBJECT+SIZE_OBJECT_REF+ 8Time SIZE_OBJECT+SIZE_OBJECT_REF+ 8Timestamp SIZE_OBJECT+SIZE_OBJECT_REF+ 12Binary SIZE_BINARY+ arrayString SIZE_STRING+ arrayarray SIZE_OBJECT+ 4 + [element size]*length()
o - the object to measure the size of
java.lang.IllegalArgumentException - if the type of the object is not one of
the classes listed aboveprotected int sizeOf(java.lang.Class clz)
Class Size boolean 1 byte 1 short 2 char 2 int 4 long 8 float 4 double 8 Object SIZE_OBJECTBoolean SIZE_OBJECT+ 1Byte SIZE_OBJECT+ 1Short SIZE_OBJECT+ 2Character SIZE_OBJECT+ 2Integer SIZE_OBJECT+ 4Long SIZE_OBJECT+ 8Float SIZE_OBJECT+ 4Double SIZE_OBJECT+ 8BigInteger SIZE_OBJECT+ 48BigDecimal SIZE_OBJECT+ 4 +SIZE_OBJECT_REF+SIZE_BIGINTEGERDate SIZE_OBJECT+SIZE_OBJECT_REF+ 8Time SIZE_OBJECT+SIZE_OBJECT_REF+ 8Timestamp SIZE_OBJECT+SIZE_OBJECT_REF+ 12
clz - the target class
java.lang.IllegalArgumentException - if the type of the object is not one of
the classes listed aboveprotected static int padMemorySize(int cb)
cb - the number of bytes to round
protected static int calculateShallowSize(java.lang.Class clz)
clz - the target class
public static void main(java.lang.String[] asArg)
java com.tangosol.net.cache.SimpleMemoryCalculator [class name]
asArg - command line arguments
|
Oracle® Coherence Java API Reference v3.5 E14977-01 |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||