public final class MemoryMXBeanImpl extends DynamicMXBeanImpl implements MemoryMXBean, javax.management.NotificationEmitter
MemoryMXBean
.
Implementation note. This type of bean is both dynamic and a notification
emitter. The dynamic behaviour comes courtesy of the
DynamicMXBeanImpl
superclass while the
notifying behaviour uses a delegation approach to a private member that
implements the NotificationEmitter
interface.
Because multiple inheritance is not supported in Java it was a toss up which
behaviour would be based on inheritence and which would use delegation. Every
other *MXBeanImpl
class in this package inherits from the
abstract base class DynamicMXBeanImpl
so that seemed to be the
natural approach for this class too. By choosing not to make this class a
subclass of NotificationBroadcasterSupport
, the
protected
handleNotification(javax.management.NotificationListener, javax.management.Notification, java.lang.Object)
method cannot be overridden for any custom notification behaviour. However,
taking the agile mantra of YAGNI to heart, it was decided that the
default implementation of that method will suffice until new requirements
prove otherwise.
info
Modifier and Type | Method and Description |
---|---|
void |
addNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback) |
void |
gc()
Requests the virtual machine to run the system garbage collector.
|
java.lang.String |
getGCMode()
Returns the current GC mode as a human-readable string.
|
java.lang.management.MemoryUsage |
getHeapMemoryUsage()
Returns the current memory usage of the heap for both live objects and
for objects no longer in use which are awaiting garbage collection.
|
long |
getMaxHeapSize()
Get the current maximum heap size in bytes.
|
long |
getMaxHeapSizeLimit()
Get the maximum size in bytes to which the max heap size could be
increased in the currently running VM.
|
long |
getMinHeapSize()
Get the minimum heap size in bytes.
|
java.lang.management.MemoryUsage |
getNonHeapMemoryUsage()
Returns the current non-heap memory usage for the virtual machine.
|
javax.management.MBeanNotificationInfo[] |
getNotificationInfo() |
int |
getObjectPendingFinalizationCount()
Returns the number of objects in the virtual machine that are awaiting
finalization.
|
long |
getSharedClassCacheFreeSpace()
Returns the free space in bytes of the cache that the JVM is
currently connected to.
|
long |
getSharedClassCacheSize()
Returns the total size in bytes of the cache that the JVM is currently
connected to.
|
boolean |
isSetMaxHeapSizeSupported()
Query whether the VM supports runtime reconfiguration of the
maximum heap size through the setMaxHeapSize() call.
|
boolean |
isVerbose()
Returns a boolean indication of whether or not the memory system is
producing verbose output.
|
void |
removeNotificationListener(javax.management.NotificationListener listener) |
void |
removeNotificationListener(javax.management.NotificationListener listener,
javax.management.NotificationFilter filter,
java.lang.Object handback) |
void |
sendNotification(javax.management.Notification notification) |
void |
setMaxHeapSize(long size)
Set the current maximum heap size to
size . |
void |
setVerbose(boolean value)
Updates the verbose output setting of the memory system.
|
getAttribute, getAttributes, getMBeanInfo, getPresentAttribute, getPresentOperation, initMBeanInfo, invoke, setAttribute, setAttributes, setMBeanInfo
public void gc()
java.lang.management.MemoryMXBean
gc
in interface java.lang.management.MemoryMXBean
public java.lang.management.MemoryUsage getHeapMemoryUsage()
java.lang.management.MemoryMXBean
getHeapMemoryUsage
in interface java.lang.management.MemoryMXBean
MemoryUsage
which can be interrogated by
the caller.public java.lang.management.MemoryUsage getNonHeapMemoryUsage()
java.lang.management.MemoryMXBean
getNonHeapMemoryUsage
in interface java.lang.management.MemoryMXBean
MemoryUsage
which can be interrogated by
the caller.public int getObjectPendingFinalizationCount()
java.lang.management.MemoryMXBean
getObjectPendingFinalizationCount
in interface java.lang.management.MemoryMXBean
public boolean isVerbose()
java.lang.management.MemoryMXBean
isVerbose
in interface java.lang.management.MemoryMXBean
true
if verbose output is being produced ;
false
otherwise.public void setVerbose(boolean value)
java.lang.management.MemoryMXBean
setVerbose
in interface java.lang.management.MemoryMXBean
value
- true
enables verbose output ;
false
disables verbose output.ManagementPermission
public long getMaxHeapSizeLimit()
MemoryMXBean
public long getMaxHeapSize()
MemoryMXBean
public long getMinHeapSize()
MemoryMXBean
public void setMaxHeapSize(long size)
MemoryMXBean
size
.
The parameter specifies the max heap size in bytes and must be
between getMinHeapSize() and getMaxHeapSizeLimit().
If this operation is not supported, this method will throw
UnsupportedOperationException.size
- new -Xsoftmx value in bytespublic boolean isSetMaxHeapSizeSupported()
MemoryMXBean
public void removeNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback) throws javax.management.ListenerNotFoundException
removeNotificationListener
in interface javax.management.NotificationEmitter
javax.management.ListenerNotFoundException
public void addNotificationListener(javax.management.NotificationListener listener, javax.management.NotificationFilter filter, java.lang.Object handback) throws java.lang.IllegalArgumentException
addNotificationListener
in interface javax.management.NotificationBroadcaster
java.lang.IllegalArgumentException
public void removeNotificationListener(javax.management.NotificationListener listener) throws javax.management.ListenerNotFoundException
removeNotificationListener
in interface javax.management.NotificationBroadcaster
javax.management.ListenerNotFoundException
public javax.management.MBeanNotificationInfo[] getNotificationInfo()
getNotificationInfo
in interface javax.management.NotificationBroadcaster
public void sendNotification(javax.management.Notification notification)
public long getSharedClassCacheSize()
MemoryMXBean
public long getSharedClassCacheFreeSpace()
MemoryMXBean
public java.lang.String getGCMode()
MemoryMXBean