java.lang.Object javax.realtime.SizeEstimator
public final class SizeEstimator
This class maintains an estimate of the amount of memory required to store a set of objects.
SizeEstimator
is a floor on the amount of memory that should
be allocated. Many objects allocate other objects when they are constructed.
SizeEstimator
only estimates the memory requirement of the object
itself, it does not include memory required for any objects allocated at
construction time.
If the instance itself is allocated in several parts (if for instance the object and its
monitor are separate), the size estimate
shall include the sum of the sizes of all the parts that are allocated from
the same memory area as the instance.
Alignment considerations, and possibly other orderdependent issues may cause the allocator to leave a small amount of unusable space, consequently the size estimate cannot be seen as more than a close estimate.
MemoryArea.MemoryArea(SizeEstimator)
,
LTMemory.LTMemory(SizeEstimator, SizeEstimator)
,
VTMemory.VTMemory(SizeEstimator, SizeEstimator)
Constructor Summary  

SizeEstimator()

Method Summary  

long 
getEstimate()
Gets an estimate of the number of bytes needed to store all the objects reserved. 
void 
reserve(java.lang.Class c,
int number)
Take into account additional number instances of
Class c when estimating the size of the
MemoryArea . 
void 
reserve(SizeEstimator size)
Take into account an additional instance of SizeEstimator size when estimating the size of the
MemoryArea . 
void 
reserve(SizeEstimator estimator,
int number)
Take into account additional number instances of
SizeEstimator size when estimating the size of the
MemoryArea . 
void 
reserveArray(int length)
Take into account an additional instance of an array of length
reference values when estimating the size of the MemoryArea . 
void 
reserveArray(int length,
java.lang.Class type)
Take into account an additional instance of an array of length
primitive values when estimating the size of the MemoryArea . 
Methods inherited from class java.lang.Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public SizeEstimator()
Method Detail 

public void reserve(java.lang.Class c, int number)
number
instances of
Class c
when estimating the size of the
MemoryArea
.
c
 The class to take into account.number
 The number of instances of c
to estimate.
java.lang.IllegalArgumentException
 Thrown if c
is null.public void reserve(SizeEstimator estimator, int number)
number
instances of
SizeEstimator size
when estimating the size of the
MemoryArea
.
estimator
 The given instance of SizeEstimator
.number
 The number of times to reserve the size denoted by
estimator
.
java.lang.IllegalArgumentException
 Thrown if estimator
is null.public void reserve(SizeEstimator size)
size
when estimating the size of the
MemoryArea
.
size
 The given instance of SizeEstimator
.
java.lang.IllegalArgumentException
 Thrown if size
is null.public void reserveArray(int length)
length
reference values when estimating the size of the MemoryArea
.
length
 The number of entries in the array.
java.lang.IllegalArgumentException
 Thrown if length
is negative.public void reserveArray(int length, java.lang.Class type)
length
primitive values when estimating the size of the MemoryArea
.
Class values for the primitive types are available from the corresponding class types; e.g., Byte.TYPE, Integer.TYPE, and Short.TYPE.
length
 The number of entries in the array.type
 The class representing a primitive type. The reservation will leave room
for an array of
length
of the primitive type corresponding to type
.
java.lang.IllegalArgumentException
 Thrown if length
is negative,
or type
does not represent a primitive type.public long getEstimate()