Interface MemoryMXBean

All Superinterfaces:
PlatformManagedObject
All Known Subinterfaces:
MemoryMXBean

public interface MemoryMXBean extends PlatformManagedObject
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.

  1. Invoking the static ManagementFactory.getMemoryMXBean() method.
  2. Using a MBeanServerConnection.
  3. 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 Type
    Method
    Description
    void
    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 a SecurityManager is being used and the caller does not have the ManagementPermission value of "control".
      See Also: