|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.util.LowMemoryNotifier
public class LowMemoryNotifier
Uses the Java 5 Management API to monitor memory usage, and notifies registered listeners when memory becomes low. Memory is partitionned into memory pools for the Management API. Each pool can have a usage threshold which triggers a notification when exceeded.
When constructing a low-memory notifier, one specifies a collection of memory pools to monitor. For each monitored pool supporting the usage threshold, the threshold is set to a fraction of the maximum memory available for that pool, the default fraction is 0.75. When memory usage exceeds this fraction, a notification is emitted by the memory pool, and this class notifies the registered low-memory listeners. If the maximum memory available for the pool has increased between the time the object was created and the low-memory notification, the usage fraction becomes smaller than the threshold usage fraction, and no listener is notified. The usage threshold of the concerned pool is then updated.
Constructor Summary | |
---|---|
LowMemoryNotifier()
Constructs a low-memory notifier with usage threshold set to 0.75 and monitoring every memory pool supporting usage threshold. |
|
LowMemoryNotifier(Collection<MemoryPoolMXBean> pools)
Constructs a low-memory notifier with usage threshold set to 0.75, and monitoring every memory pool in pools supporting usage threshold. |
|
LowMemoryNotifier(Collection<MemoryPoolMXBean> pools,
double usageThreshold)
Constructs a low-memory notifier with usage threshold set to usageThreshold, and monitoring every memory pool in pools supporting usage threshold. |
|
LowMemoryNotifier(double usageThreshold)
Constructs a low-memory notifier with usage threshold set to usageThreshold and monitoring every memory pool supporting usage threshold. |
Method Summary | |
---|---|
void |
addLowMemoryListener(LowMemoryListener listener1)
Registers the low-memory listener listener. |
List<LowMemoryListener> |
getLowMemoryListeners()
Returns the low-memory listeners currently registered with this object. |
Collection<MemoryPoolMXBean> |
getMemoryPools()
Returns the memory pools monitored by this object. |
double |
getUsageThreshold()
Returns the usage threshold used by this low-memory notifier. |
void |
removeLowMemoryListener(LowMemoryListener listener1)
Unregisters the low-memory listener listener. |
void |
removeLowMemoryListeners()
Removes all low-memory listeners registered with this object. |
void |
setUsageThreshold(double usageThreshold)
Sets the usage threshold used by this low-memory notifier to usageThreshold |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LowMemoryNotifier()
public LowMemoryNotifier(double usageThreshold)
usageThreshold
- the usage threshold.
IllegalArgumentException
- if usageThreshold
is smaller than 0 or greater than 1.public LowMemoryNotifier(Collection<MemoryPoolMXBean> pools)
pools
- the collection of memory pools.
NullPointerException
- if pools is null.public LowMemoryNotifier(Collection<MemoryPoolMXBean> pools, double usageThreshold)
pools
- the collection of memory pools.usageThreshold
- the usage threshold.
NullPointerException
- if pools is null.
IllegalArgumentException
- if usageThreshold
is smaller than 0 or greater than 1.Method Detail |
---|
public void addLowMemoryListener(LowMemoryListener listener1)
listener1
- the new low-memory listener to be registered.
NullPointerException
- if listener is null.public void removeLowMemoryListener(LowMemoryListener listener1)
listener1
- the low-memory listener to be unregistered.public void removeLowMemoryListeners()
public List<LowMemoryListener> getLowMemoryListeners()
public double getUsageThreshold()
public void setUsageThreshold(double usageThreshold)
usageThreshold
- the current usage threshold.
IllegalArgumentException
- if usageThreshold
is smaller than 0 or greater than 1.public Collection<MemoryPoolMXBean> getMemoryPools()
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |