public final class SizeEstimator
extends java.lang.Object
Jamaica Real-Time Specification for Java class SizeEstimator.
This class permits to estimate the memory required for the allocation of Java objects and arrays. It determines a lower bound for the memory required to allocate all instances and arrays function reserve() will be called for.
Constructor and Description |
---|
SizeEstimator()
Constructor to create estimate with no entries.
|
Modifier and Type | Method and Description |
---|---|
long |
getEstimate()
getEstimate returns the current estimate in number of bytes.
|
void |
reserve(java.lang.Class<?> clazz,
int num)
reserve reserves space for num instances of class clazz.
|
void |
reserve(SizeEstimator size)
reserve reserves space for the memory reserved by SizeEstimator
size.
|
void |
reserve(SizeEstimator size,
int num)
reserve reserves space for the num times the memory reserved by
SizeEstimator size.
|
void |
reserveArray(int length)
reserveArray reserves space for an instance of a reference array
of given length.
|
void |
reserveArray(int length,
java.lang.Class type)
reserveArray reserves space for an of an array of primitive type
and length elements when estimating the size of the MemoryArea.
|
public SizeEstimator()
public long getEstimate()
public void reserve(java.lang.Class<?> clazz, int num)
clazz
- the class of the new instancesnum
- the number of instances.java.lang.IllegalArgumentException
- if clazz is null or num is
negative.public void reserve(SizeEstimator size)
size
- another SizeEstimator.java.lang.IllegalArgumentException
- if size is null.public void reserve(SizeEstimator size, int num)
size
- another SizeEstimator.num
- factor to multiply the space from size with.java.lang.IllegalArgumentException
- if size is null or num < 0.public void reserveArray(int length)
length
- the length of the reference array we want to
reserve space for.java.lang.IllegalArgumentException
- if length < 0.public void reserveArray(int length, java.lang.Class type)
length
- the length of the primitive array we want to
reserve space for.type
- the primitive element type, must be one of
Boolean.TYPE, Byte.TYPE, Short.TYPE, Character.TYPE,
Integer.Type, Float.TYPE, Long.TYPE, or Double.TYPE.java.lang.IllegalArgumentException
- iff length is negative or type
is not a primitive element type.