Class ExtendedMemoryMXBeanImpl
- All Implemented Interfaces:
MemoryMXBean, MemoryMXBean, PlatformManagedObject, NotificationBroadcaster, NotificationEmitter
MemoryMXBean.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Adds a listener to this MBean.voidgc()Runs the garbage collector.intReturns a list of all of the instances ofGarbageCollectorMXBeanin this virtual machine.longlongReturns the current memory usage of the heap that is used for object allocation.static ExtendedMemoryMXBeanImpllonglongintgetMemoryManagerMXBeans(boolean copy) Retrieves the list of memory manager beans in the system.getMemoryPoolMXBeans(boolean copy) Retrieves the list of memory pool beans managed by this manager.longReturns the current memory usage of non-heap memory that is used by the Java virtual machine.Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.Returns anObjectNameinstance representing the object name of this platform managed object.intReturns the approximate number of objects for which finalization is pending.longlonglonglonglonglonglonglonglonglonglongReturns the approximate accumulated time, in nanoseconds, spent in garbage collection (GC).booleanbooleanTests if verbose output for the memory system is enabled.protected GarbageCollectorMXBeanmakeGCBean(String domainName, String name, int internalID) Create a new GarbageCollectorMXBean.protected MemoryPoolMXBeanmakeMemoryPoolBean(String name, MemoryType type, int internalID) Create a new MemoryPoolMXBean.final voidRemoves a listener from this MBean.final voidremoveNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) Removes a listener from this MBean.final voidsendNotification(Notification notification) Send notifications to registered listeners.voidsetMaxHeapSize(long size) booleansetSharedClassCacheMaxAotBytes(long value) booleansetSharedClassCacheMaxJitDataBytes(long value) booleansetSharedClassCacheMinAotBytes(long value) booleansetSharedClassCacheMinJitDataBytes(long value) booleansetSharedClassCacheSoftmxBytes(long value) voidsetVerbose(boolean value) Enables or disables verbose output for the memory system.protected voidEnsure the notification thread is running.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface MemoryMXBean
getCurrentGCThreads, getGCMainThreadCpuUsed, getGCMode, getGCWorkerThreadsCpuUsed, getMaxHeapSize, getMaxHeapSizeLimit, getMaximumGCThreads, getMinHeapSize, getSharedClassCacheFreeSpace, getSharedClassCacheMaxAotBytes, getSharedClassCacheMaxAotUnstoredBytes, getSharedClassCacheMaxJitDataBytes, getSharedClassCacheMaxJitDataUnstoredBytes, getSharedClassCacheMinAotBytes, getSharedClassCacheMinJitDataBytes, getSharedClassCacheSize, getSharedClassCacheSoftmxBytes, getSharedClassCacheSoftmxUnstoredBytes, isSetMaxHeapSizeSupported, setMaxHeapSize, setSharedClassCacheMaxAotBytes, setSharedClassCacheMaxJitDataBytes, setSharedClassCacheMinAotBytes, setSharedClassCacheMinJitDataBytes, setSharedClassCacheSoftmxBytesModifier and TypeMethodDescriptionintReturns the number of GC worker threads that participated in the most recent collection.longReturns the amount of CPU time spent in the GC by the main thread, in milliseconds.Returns the current GC mode as a human-readable string.longReturns the total amount of CPU time spent in the GC by all worker threads, in milliseconds.longGet the current maximum heap size in bytes.longGet the maximum size in bytes to which the max heap size could be increased in the currently running VM.intReturns the maximum number of GC worker threads.longGet the minimum heap size in bytes.longReturns the free space in bytes of the cache that the JVM is currently connected to.longReturns the maximum space allowed for AOT data of the cache that the JVM is currently connected to.longReturns the bytes which are not stored into the shared classes cache due to the current setting of maximum space allowed for AOT data.longReturns the maximum space allowed for JIT data of the cache that the JVM is currently connected to.longReturns the bytes which are not stored into the shared classes cache due to the current setting of maximum space allowed for JIT data.longReturns the minimum space reserved for AOT data of the cache that the JVM is currently connected to.longReturns the minimum space reserved for JIT data of the cache that the JVM is currently connected to.longReturns the total size in bytes of the cache that the JVM is currently connected to.longReturns the softmx size in bytes of the cache that the JVM is currently connected to.longReturns the bytes which are not stored into the shared classes cache due to the current setting of softmx in shared classes.booleanQuery whether the VM supports runtime reconfiguration of the maximum heap size through the setMaxHeapSize() call.voidsetMaxHeapSize(long size) Set the current maximum heap size tosize.booleansetSharedClassCacheMaxAotBytes(long value) Set the maximum shared classes cache space allowed for AOT data tovaluebytes.booleansetSharedClassCacheMaxJitDataBytes(long value) Set the maximum shared classes cache space allowed for JIT data tovaluebytes.booleansetSharedClassCacheMinAotBytes(long value) Set the minimum shared classes cache space reserved for AOT data tovaluebytes.booleansetSharedClassCacheMinJitDataBytes(long value) Set the minimum shared classes cache space reserved for JIT data tovaluebytes.booleansetSharedClassCacheSoftmxBytes(long value) Set the shared class softmx size tovalue.
-
Method Details
-
getInstance
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException Adds a listener to this MBean.- Specified by:
addNotificationListenerin interfaceNotificationBroadcaster- Parameters:
listener- The listener object which will handle the notifications emitted by the broadcaster.filter- The filter object. If filter is null, no filtering will be performed before handling notifications.handback- An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.- Throws:
IllegalArgumentException- Listener parameter is null.- See Also:
-
startNotificationThread
protected void startNotificationThread()Ensure the notification thread is running. -
makeGCBean
Create a new GarbageCollectorMXBean.- Parameters:
domainName- the domain name of the new beanname- the collector nameinternalID- an internal id number representing the collector- Returns:
- the new GarbageCollectorMXBean
-
makeMemoryPoolBean
Create a new MemoryPoolMXBean.- Parameters:
name- the name of the memory pooltype- the type of the memory poolinternalID- an internal id number representing the memory pool- Returns:
- the new MemoryPoolMXBean
-
getMemoryManagerMXBeans
Retrieves the list of memory manager beans in the system.- Parameters:
copy- indicates whether a copy of the list should be returned- Returns:
- the list of
MemoryManagerMXBeaninstances
-
getGarbageCollectorMXBeans
Returns a list of all of the instances ofGarbageCollectorMXBeanin this virtual machine. Owing to the dynamic nature of this kind ofMXBean, it is possible that instances may be created or destroyed between the invocation and return of this method.- Returns:
- a list of all known
GarbageCollectorMXBeans in this virtual machine.
-
getMemoryPoolMXBeans
Retrieves the list of memory pool beans managed by this manager.- Parameters:
copy- indicates whether a copy of the list should be returned- Returns:
- the list of
MemoryPoolMXBeaninstances
-
gc
public void gc()Runs the garbage collector. The callgc()is effectively equivalent to the call:System.gc()
- Specified by:
gcin interfaceMemoryMXBean- See Also:
-
getHeapMemoryUsage
Returns the current memory usage of the heap that is used for object allocation. The heap consists of one or more memory pools. Theusedandcommittedsize of the returned memory usage is the sum of those values of all heap memory pools whereas theinitandmaxsize of the returned memory usage represents the setting of the heap memory which may not be the sum of those of all heap memory pools.The amount of used memory in the returned memory usage is the amount of memory occupied by both live objects and garbage objects that have not been collected, if any.
MBeanServer access:
The mapped type ofMemoryUsageisCompositeDatawith attributes as specified inMemoryUsage.- Specified by:
getHeapMemoryUsagein interfaceMemoryMXBean- Returns:
- a
MemoryUsageobject representing the heap memory usage.
-
getNonHeapMemoryUsage
Returns the current memory usage of non-heap memory that is used by the Java virtual machine. The non-heap memory consists of one or more memory pools. Theusedandcommittedsize of the returned memory usage is the sum of those values of all non-heap memory pools whereas theinitandmaxsize of the returned memory usage represents the setting of the non-heap memory which may not be the sum of those of all non-heap memory pools.MBeanServer access:
The mapped type ofMemoryUsageisCompositeDatawith attributes as specified inMemoryUsage.- Specified by:
getNonHeapMemoryUsagein interfaceMemoryMXBean- Returns:
- a
MemoryUsageobject representing the non-heap memory usage.
-
getObjectPendingFinalizationCount
public int getObjectPendingFinalizationCount()Returns the approximate number of objects for which finalization is pending.- Specified by:
getObjectPendingFinalizationCountin interfaceMemoryMXBean- Returns:
- the approximate number objects for which finalization is pending. If this MemoryMXBean contains information about a JVM in which finalization has been disabled or removed, this method always returns zero.
-
isVerbose
public boolean isVerbose()Tests if verbose output for the memory system is enabled.- Specified by:
isVerbosein interfaceMemoryMXBean- Returns:
trueif verbose output for the memory system is enabled;falseotherwise.
-
setVerbose
public void setVerbose(boolean value) Enables or disables verbose output for the memory system. The verbose output information and the output stream to which the verbose information is emitted are implementation dependent. Typically, a Java virtual machine implementation prints a message whenever it frees memory at garbage collection.Each invocation of this method enables or disables verbose output globally.
- Specified by:
setVerbosein interfaceMemoryMXBean- Parameters:
value-trueto enable verbose output;falseto disable.
-
getMaxHeapSizeLimit
public long getMaxHeapSizeLimit() -
getMaxHeapSize
public long getMaxHeapSize() -
getMinHeapSize
public long getMinHeapSize() -
setMaxHeapSize
public void setMaxHeapSize(long size) -
isSetMaxHeapSizeSupported
public boolean isSetMaxHeapSizeSupported() -
getNotificationInfo
Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.
It is not illegal for the MBean to send notifications not described in this array. However, some clients of the MBean server may depend on the array being complete for their correct functioning.
- Specified by:
getNotificationInfoin interfaceNotificationBroadcaster- Returns:
- the array of possible notifications.
-
getGCMode
-
getGCMainThreadCpuUsed
public long getGCMainThreadCpuUsed() -
getGCWorkerThreadsCpuUsed
public long getGCWorkerThreadsCpuUsed() -
getMaximumGCThreads
public int getMaximumGCThreads() -
getCurrentGCThreads
public int getCurrentGCThreads() -
getObjectName
Returns anObjectNameinstance representing the object name of this platform managed object.- Specified by:
getObjectNamein interfacePlatformManagedObject- Returns:
- an
ObjectNameinstance representing the object name of this platform managed object.
-
getTotalGcCpuTime
public long getTotalGcCpuTime()Returns the approximate accumulated time, in nanoseconds, spent in garbage collection (GC).The time spent in spent in GC is the CPU time used by all GC activity, including any overhead, which means the result may be non-zero even if no GC has occurred. This method returns
-1if the platform does not support this operation or the information is not available.- Specified by:
getTotalGcCpuTimein interfaceMemoryMXBean- Returns:
- the total accumulated CPU time for GC in
nanoseconds, or
-1.
-
removeNotificationListener
public final void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException Removes a listener from this MBean. If the listener has been registered with different handback objects or notification filters, all entries corresponding to the listener will be removed.- Specified by:
removeNotificationListenerin interfaceNotificationBroadcaster- Parameters:
listener- A listener that was previously added to this MBean.- Throws:
ListenerNotFoundException- The listener is not registered with the MBean.- See Also:
-
removeNotificationListener
public final void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException Removes a listener from this MBean. The MBean must have a listener that exactly matches the given
listener,filter, andhandbackparameters. If there is more than one such listener, only one is removed.The
filterandhandbackparameters may be null if and only if they are null in a listener to be removed.- Specified by:
removeNotificationListenerin interfaceNotificationEmitter- Parameters:
listener- A listener that was previously added to this MBean.filter- The filter that was specified when the listener was added.handback- The handback that was specified when the listener was added.- Throws:
ListenerNotFoundException- The listener is not registered with the MBean, or it is not registered with the given filter and handback.
-
sendNotification
Send notifications to registered listeners.- Parameters:
notification- a notification to be sent
-