public class MemoryParameters extends Object implements Serializable, Cloneable
An instance of MemoryParameters can be associated with a schedulable object to describe and limit the memory allocation characteristics of this schedulable object. If a schedulable object exceeds the limits specified by its MemoryParameters, an OutOfMemoryError will be thrown on the allocation.
A memory parameters object that is shared by several schedulable objects does not mean that all those schedulable object will not exceed the allocation limits of this MemoryParameters object. Instead, the limits apply to each single schedulable object only.
NOTE: the methods in this class are not synchronized. They cannot be used by several threads simultaneously without proper explicit synchronization.
Modifier and Type | Field and Description |
---|---|
static long |
NO_MAX
This value specifies no limit on the allocation budget.
|
static long |
UNLIMITED
Specifies no maximum limit.
|
Constructor and Description |
---|
MemoryParameters(long maxMemoryArea,
long maxImmortal)
Constructor to create a MemoryParameters with given maximum
allocation budgets.
|
MemoryParameters(long maxMemoryArea,
long maxImmortal,
long allocationRate)
Constructor to create a MemoryParameters with given maximum
allocation budgets.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
clone create a clone of this object with the same parameters but
without association to any schedulable object
|
long |
getAllocationRate()
getAllocationRate returns the current maximum allocation rate in
bytes per second.
|
long |
getMaxImmortal()
getMaxImmortal returns the current limit on the allocation allowed
in the immortal memory area.
|
long |
getMaxMemoryArea()
getMaxMemoryArea returns the limit on the allocation allowed in
the initial memory area.
|
void |
setAllocationRate(long allocationRate)
setAllocationRate sets the current maximum allocation rate in
bytes per second.
|
boolean |
setAllocationRateIfFeasible(long allocationRate)
setAllocationRateIfFeasible first checks if the schedulables
associated with this would still be feasible with the new
allocation rate.
|
boolean |
setMaxImmortalIfFeasible(long maximum)
setMaxImmortalIfFeasible first checks if the schedulables
associated with this would still be feasible with the new
immortal allocation limit.
|
boolean |
setMaxMemoryAreaIfFeasible(long maximum)
setMaxMemoryAreaIfFeasible first checks if the schedulables
associated with this would still be feasible with the new
allocation limit.
|
public static final long UNLIMITED
public static final long NO_MAX
public MemoryParameters(long maxMemoryArea, long maxImmortal) throws StaticIllegalArgumentException
StaticIllegalArgumentException
- if maxMemoryArea or maxImmortal
is negative and not NO_MAX.maxMemoryArea
- The limit on the allocation allowed in the
initial memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.maxImmortal
- The limit on the allocation allowed in the
immortal memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.public MemoryParameters(long maxMemoryArea, long maxImmortal, long allocationRate) throws StaticIllegalArgumentException
StaticIllegalArgumentException
- if maxMemoryArea, maxImmortal or
allocationRate is negative and not NO_MAX.maxMemoryArea
- The limit on the allocation allowed in the
initial memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.maxImmortal
- The limit on the allocation allowed in the
immortal memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.allocationRate
- the maximum allocation rate in bytes per
second allowed on the heap. zero means no allocation is allowed
on the heap, NO_MAX means no limit on the allocation
rate. Measurement starts when the schedulable object is first
released. Enforcement of the allocation rate is an implementation
option and is not implemented for JamaicaVM. The garbage
collector of JamaicaVM is not paced, so it is not required to
restrict the allocation rate of the application to work properly.public long getAllocationRate()
public long getMaxImmortal()
public long getMaxMemoryArea()
public void setAllocationRate(long allocationRate)
StaticIllegalArgumentException
- if allocationRate is negative
and not NO_MAX.allocationRate
- the maximum allocation rate in bytes per
second allowed on the heap. zero means no allocation is allowed
on the heap, NO_MAX means no limit on the allocation
rate. Measurement starts when the schedulable object is first
released. Enforcement of the allocation rate is an implementation
option and is not implemented for JamaicaVM. The garbage
collector of JamaicaVM is not paced, so it is not required to
restrict the allocation rate of the application to work properly.public boolean setMaxImmortalIfFeasible(long maximum)
StaticIllegalArgumentException
- if maximum is negative and not
NO_MAX.maximum
- The limit on the allocation allowed in the
immortal memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.public boolean setMaxMemoryAreaIfFeasible(long maximum)
StaticIllegalArgumentException
- if maximum is negative and not
NO_MAX.maximum
- The limit on the allocation allowed in the
initial memory area. zero implies that no allocation is allowed,
NO_MAX does not restrict the amount of allocation.public boolean setAllocationRateIfFeasible(long allocationRate)
StaticIllegalArgumentException
- if allocationRate is negative
and not NO_MAX.allocationRate
- the maximum allocation rate in bytes per
second allowed on the heap. zero means no allocation is allowed
on the heap, NO_MAX means no limit on the allocation
rate. Measurement starts when the schedulable object is first
released. Enforcement of the allocation rate is an implementation
option and it is not implemented for JamaicaVM. The garbage
collector of JamaicaVM is not paced, so it is not required to
restrict the allocation rate of the application to work properly.public Object clone()
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.