- All Superinterfaces:
PlatformManagedObject
- All Known Subinterfaces:
MemoryMXBean
The management and monitoring interface for a virtual machine's memory
system.
Precisely one instance of this interface will be made available to management clients.
Accessing this MXBean
can be done in one of three ways.
- Invoking the static
ManagementFactory.getMemoryMXBean()
method. - Using a
MBeanServerConnection
. - Obtaining a proxy MXBean from the static
ManagementFactory.newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class<T>)
method, passing in the string "java.lang:type=ClassLoading" for the value of the second parameter.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
gc()
Requests the virtual machine to run the system garbage collector.Returns the current memory usage of the heap for both live objects and for objects no longer in use which are awaiting garbage collection.Returns the current non-heap memory usage for the virtual machine.int
Returns the number of objects in the virtual machine that are awaiting finalization.boolean
Returns a boolean indication of whether or not the memory system is producing verbose output.void
setVerbose
(boolean value) Updates the verbose output setting of the memory system.Methods declared in interface java.lang.management.PlatformManagedObject
getObjectName
-
Method Details
-
gc
void gc()Requests the virtual machine to run the system garbage collector. -
getHeapMemoryUsage
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.- Returns:
- an instance of
MemoryUsage
which can be interrogated by the caller.
-
getNonHeapMemoryUsage
MemoryUsage getNonHeapMemoryUsage()Returns the current non-heap memory usage for the virtual machine.- Returns:
- an instance of
MemoryUsage
which can be interrogated by the caller.
-
getObjectPendingFinalizationCount
int getObjectPendingFinalizationCount()Returns the number of objects in the virtual machine that are awaiting finalization. The returned value should only be used as an approximate guide.- Returns:
- the number of objects awaiting finalization.
-
isVerbose
boolean isVerbose()Returns a boolean indication of whether or not the memory system is producing verbose output.- Returns:
true
if verbose output is being produced ;false
otherwise.
-
setVerbose
void setVerbose(boolean value) Updates the verbose output setting of the memory system.- Parameters:
value
-true
enables verbose output ;false
disables verbose output.- Throws:
SecurityException
- if aSecurityManager
is being used and the caller does not have theManagementPermission
value of "control".- See Also:
-