jdk/src/share/classes/java/lang/management/MemoryMXBean.java
author mchung
Tue, 29 Mar 2011 15:50:55 -0700
changeset 9013 eedac0b9f552
parent 5506 202f599c92aa
child 18799 31062cb3cc8e
permissions -rw-r--r--
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The management interface for the memory system of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the Java virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p> A Java virtual machine has a single instance of the implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * class of this interface.  This instance implementing this interface is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * an <a href="ManagementFactory.html#MXBean">MXBean</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * that can be obtained by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the {@link ManagementFactory#getMemoryMXBean} method or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * from the {@link ManagementFactory#getPlatformMBeanServer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * platform <tt>MBeanServer</tt>} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the memory system within an MBeanServer is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *    {@link ManagementFactory#MEMORY_MXBEAN_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *           <tt>java.lang:type=Memory</tt>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    49
 * It can be obtained by calling the
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    50
 * {@link PlatformManagedObject#getObjectName} method.
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
    51
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <h4> Memory </h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * The memory system of the Java virtual machine manages
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * the following kinds of memory:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <h4> 1. Heap </h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * The Java virtual machine has a <i>heap</i> that is the runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * data area from which memory for all class instances and arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * are allocated.  It is created at the Java virtual machine start-up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * Heap memory for objects is reclaimed by an automatic memory management
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * system which is known as a <i>garbage collector</i>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>The heap may be of a fixed size or may be expanded and shrunk.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * The memory for the heap does not need to be contiguous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <h4> 2. Non-Heap Memory</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * The Java virtual machine manages memory other than the heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * (referred as <i>non-heap memory</i>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <p> The Java virtual machine has a <i>method area</i> that is shared
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * among all threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * The method area belongs to non-heap memory.  It stores per-class structures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * such as a runtime constant pool, field and method data, and the code for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * methods and constructors.  It is created at the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * start-up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p> The method area is logically part of the heap but a Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * machine implementation may choose not to either garbage collect
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * or compact it.  Similar to the heap, the method area may be of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * fixed size or may be expanded and shrunk.  The memory for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * method area does not need to be contiguous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <p>In addition to the method area, a Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * implementation may require memory for internal processing or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * optimization which also belongs to non-heap memory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * For example, the JIT compiler requires memory for storing the native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * machine code translated from the Java virtual machine code for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * high performance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <h4>Memory Pools and Memory Managers</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * {@link MemoryPoolMXBean Memory pools} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * {@link MemoryManagerMXBean memory managers} are the abstract entities
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * that monitor and manage the memory system
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * of the Java virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * <p>A memory pool represents a memory area that the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * manages.  The Java virtual machine has at least one memory pool
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * and it may create or remove memory pools during execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * A memory pool can belong to either the heap or the non-heap memory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <p>A memory manager is responsible for managing one or more memory pools.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * The garbage collector is one type of memory manager responsible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * for reclaiming memory occupied by unreachable objects.  A Java virtual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * machine may have one or more memory managers.   It may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * add or remove memory managers during execution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * A memory pool can be managed by more than one memory manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <h4>Memory Usage Monitoring</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * Memory usage is a very important monitoring attribute for the memory system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * The memory usage, for example, could indicate:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *   <li>the memory usage of an application,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *   <li>the workload being imposed on the automatic memory management system,</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *   <li>potential memory leakage.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * The memory usage can be monitored in three ways:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *   <li>Polling</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *   <li>Usage Threshold Notification</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *   <li>Collection Usage Threshold Notification</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * Details are specified in the {@link MemoryPoolMXBean} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * <p>The memory usage monitoring mechanism is intended for load-balancing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * or workload distribution use.  For example, an application would stop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * receiving any new workload when its memory usage exceeds a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * certain threshold. It is not intended for an application to detect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * and recover from a low memory condition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * <h4>Notifications</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * <p>This <tt>MemoryMXBean</tt> is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * {@link javax.management.NotificationEmitter NotificationEmitter}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * that emits two types of memory {@link javax.management.Notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * notifications} if any one of the memory pools
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * supports a <a href="MemoryPoolMXBean.html#UsageThreshold">usage threshold</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * or a <a href="MemoryPoolMXBean.html#CollectionThreshold">collection usage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * threshold</a> which can be determined by calling the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * {@link MemoryPoolMXBean#isUsageThresholdSupported} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * {@link MemoryPoolMXBean#isCollectionUsageThresholdSupported} methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *   <li>{@link MemoryNotificationInfo#MEMORY_THRESHOLD_EXCEEDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *       usage threshold exceeded notification} - for notifying that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *       the memory usage of a memory pool is increased and has reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *       or exceeded its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *       <a href="MemoryPoolMXBean.html#UsageThreshold"> usage threshold</a> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 *       </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *   <li>{@link MemoryNotificationInfo#MEMORY_COLLECTION_THRESHOLD_EXCEEDED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *       collection usage threshold exceeded notification} - for notifying that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 *       the memory usage of a memory pool is greater than or equal to its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *       <a href="MemoryPoolMXBean.html#CollectionThreshold">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 *       collection usage threshold</a> after the Java virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *       has expended effort in recycling unused objects in that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *       memory pool.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * The notification emitted is a {@link javax.management.Notification}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * instance whose {@link javax.management.Notification#setUserData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * user data} is set to a {@link CompositeData CompositeData}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * that represents a {@link MemoryNotificationInfo} object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * containing information about the memory pool when the notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * was constructed. The <tt>CompositeData</tt> contains the attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * as described in {@link MemoryNotificationInfo#from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * MemoryNotificationInfo}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * <hr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * <h4>NotificationEmitter</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * The <tt>MemoryMXBean</tt> object returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * {@link ManagementFactory#getMemoryMXBean} implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * the {@link javax.management.NotificationEmitter NotificationEmitter}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * interface that allows a listener to be registered within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * <tt>MemoryMXBean</tt> as a notification listener.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * Below is an example code that registers a <tt>MyListener</tt> to handle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * notification emitted by the <tt>MemoryMXBean</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * class MyListener implements javax.management.NotificationListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 *     public void handleNotification(Notification notif, Object handback) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 *         // handle notification
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 *         ....
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * NotificationEmitter emitter = (NotificationEmitter) mbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * MyListener listener = new MyListener();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * emitter.addNotificationListener(listener, null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 *
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   196
 * @see ManagementFactory#getPlatformMXBeans(Class)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * @see <a href="../../../javax/management/package-summary.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 *      JMX Specification.</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * @see <a href="package-summary.html#examples">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 *      Ways to Access MXBeans</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * @author  Mandy Chung
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 */
401
ef01e0dccd63 6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents: 2
diff changeset
   205
public interface MemoryMXBean extends PlatformManagedObject {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Returns the approximate number of objects for which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * finalization is pending.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @return the approximate number objects for which finalization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * is pending.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public int getObjectPendingFinalizationCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns the current memory usage of the heap that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * is used for object allocation.  The heap consists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * of one or more memory pools.  The <tt>used</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * and <tt>committed</tt> size of the returned memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * usage is the sum of those values of all heap memory pools
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * whereas the <tt>init</tt> and <tt>max</tt> size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * returned memory usage represents the setting of the heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * memory which may not be the sum of those of all heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * memory pools.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * The amount of used memory in the returned memory usage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * is the amount of memory occupied by both live objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * and garbage objects that have not been collected, if any.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * The mapped type of <tt>MemoryUsage</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * <tt>CompositeData</tt> with attributes as specified in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * {@link MemoryUsage#from MemoryUsage}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @return a {@link MemoryUsage} object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * the heap memory usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public MemoryUsage getHeapMemoryUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Returns the current memory usage of non-heap memory that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * is used by the Java virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * The non-heap memory consists of one or more memory pools.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * The <tt>used</tt> and <tt>committed</tt> size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * returned memory usage is the sum of those values of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * all non-heap memory pools whereas the <tt>init</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * and <tt>max</tt> size of the returned memory usage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * represents the setting of the non-heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * memory which may not be the sum of those of all non-heap
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * memory pools.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * <b>MBeanServer access</b>:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * The mapped type of <tt>MemoryUsage</tt> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * <tt>CompositeData</tt> with attributes as specified in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * {@link MemoryUsage#from MemoryUsage}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return a {@link MemoryUsage} object representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * the non-heap memory usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public MemoryUsage getNonHeapMemoryUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Tests if verbose output for the memory system is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @return <tt>true</tt> if verbose output for the memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * system is enabled; <tt>false</tt> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public boolean isVerbose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * Enables or disables verbose output for the memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * system.  The verbose output information and the output stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * to which the verbose information is emitted are implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * dependent.  Typically, a Java virtual machine implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * prints a message whenever it frees memory at garbage collection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Each invocation of this method enables or disables verbose
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * output globally.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param value <tt>true</tt> to enable verbose output;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *              <tt>false</tt> to disable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @exception  java.lang.SecurityException if a security manager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *             exists and the caller does not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *             ManagementPermission("control").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void setVerbose(boolean value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * Runs the garbage collector.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * The call <code>gc()</code> is effectively equivalent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <blockquote><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * System.gc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * </pre></blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @see     java.lang.System#gc()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    public void gc();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
}