VMware GemFire Java API Reference
Package org.apache.geode.cache.util
Interface ObjectSizer
-
public interface ObjectSizerThe sizer interface defines a method that when called returns the size of the object passed in. Implementations may return hardcoded values for object size if the implementation knows the object size for all objects that are likely to be cached. You should use a sizer with aEvictionAttributes.createLRUHeapAttributes(ObjectSizer)orEvictionAttributes.createLRUMemoryAttributes(ObjectSizer)if you want to use a faster or more accurate method of sizing than provided by the default object sizer, which isSIZE_CLASS_ONCE- Since:
- GemFire 3.0
-
-
Field Summary
Fields Modifier and Type Field Description static ObjectSizerDEFAULTThe default object sizer, currentlySIZE_CLASS_ONCEstatic ObjectSizerREFLECTION_SIZEAn implementation ofObjectSizerthat calculates an accurate size for each object that it sizes.static ObjectSizerSIZE_CLASS_ONCEAn implementation ofObjectSizerthat calculates an accurate size of the first instance of each class that is put in the cache.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intsizeof(java.lang.Object o)
-
-
-
Field Detail
-
SIZE_CLASS_ONCE
@Immutable static final ObjectSizer SIZE_CLASS_ONCE
An implementation ofObjectSizerthat calculates an accurate size of the first instance of each class that is put in the cache. After the first instance, it will return the same size for every instance of that class. This sizer is a compromise between generating accurate sizes for every object and performance. It should work well if the keys and values in the region don't vary greatly in size. For accurate sizing of every instance useREFLECTION_SIZEinstead. This sizer does generate an accurate size for strings and byte arrays every time, because there is very little performance impact from sizing these objects.- Since:
- GemFire 6.5
-
REFLECTION_SIZE
@Immutable static final ObjectSizer REFLECTION_SIZE
An implementation ofObjectSizerthat calculates an accurate size for each object that it sizes. This sizer will add up the sizes of all objects that are reachable from the keys and values in your region by non-static fields. For objects that are all approximately the same size, consider usingSIZE_CLASS_ONCE. It will have much better performance.- Since:
- GemFire 6.5
-
DEFAULT
@Immutable static final ObjectSizer DEFAULT
The default object sizer, currentlySIZE_CLASS_ONCE- Since:
- GemFire 6.5
-
-