public interface ObjectSizer
EvictionAttributes.createLRUHeapAttributes(ObjectSizer)
or EvictionAttributes.createLRUMemoryAttributes(ObjectSizer)
if you want
to use a faster or more accurate method of sizing than provided by the default
object sizer, which is {#link SIZE_CLASS_ONCE
Modifier and Type | Field and Description |
---|---|
static ObjectSizer |
DEFAULT
The default object sizer, currently
SIZE_CLASS_ONCE |
static ObjectSizer |
REFLECTION_SIZE
An implementation of
ObjectSizer that calculates an accurate size
for each object that it sizes. |
static ObjectSizer |
SIZE_CLASS_ONCE
An implementation of
ObjectSizer that calculates an accurate size
of the first instance of each class that is put in the cache. |
static final ObjectSizer SIZE_CLASS_ONCE
ObjectSizer
that 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 use
REFLECTION_SIZE
instead.
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.static final ObjectSizer REFLECTION_SIZE
ObjectSizer
that 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 using
SIZE_CLASS_ONCE
. It will have much better performance.static final ObjectSizer DEFAULT
SIZE_CLASS_ONCE
int sizeof(Object o)
Copyright © 1997-2017 Pivotal Software, Inc. All rights reserved.