Path: blob/master/src/java.management/share/classes/java/lang/management/GarbageCollectorMXBean.java
41159 views
/*1* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.lang.management;2627/**28* The management interface for the garbage collection of29* the Java virtual machine. Garbage collection is the process30* that the Java virtual machine uses to find and reclaim unreachable31* objects to free up memory space. A garbage collector is one type of32* {@link MemoryManagerMXBean memory manager}.33*34* <p> A Java virtual machine may have one or more instances of35* the implementation class of this interface.36* An instance implementing this interface is37* an <a href="ManagementFactory.html#MXBean">MXBean</a>38* that can be obtained by calling39* the {@link ManagementFactory#getGarbageCollectorMXBeans} method or40* from the {@link ManagementFactory#getPlatformMBeanServer41* platform MBeanServer} method.42*43* <p>The {@code ObjectName} for uniquely identifying the MXBean for44* a garbage collector within an MBeanServer is:45* <blockquote>46* {@link ManagementFactory#GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE47* java.lang:type=GarbageCollector}{@code ,name=}<i>collector's name</i>48* </blockquote>49*50* It can be obtained by calling the51* {@link PlatformManagedObject#getObjectName} method.52*53* A platform usually includes additional platform-dependent information54* specific to a garbage collection algorithm for monitoring.55*56* @see ManagementFactory#getPlatformMXBeans(Class)57* @see MemoryMXBean58*59* @see <a href="../../../javax/management/package-summary.html">60* JMX Specification.</a>61* @see <a href="package-summary.html#examples">62* Ways to Access MXBeans</a>63*64* @author Mandy Chung65* @since 1.566*/67public interface GarbageCollectorMXBean extends MemoryManagerMXBean {68/**69* Returns the total number of collections that have occurred.70* This method returns {@code -1} if the collection count is undefined for71* this collector.72*73* @return the total number of collections that have occurred.74*/75public long getCollectionCount();7677/**78* Returns the approximate accumulated collection elapsed time79* in milliseconds. This method returns {@code -1} if the collection80* elapsed time is undefined for this collector.81* <p>82* The Java virtual machine implementation may use a high resolution83* timer to measure the elapsed time. This method may return the84* same value even if the collection count has been incremented85* if the collection elapsed time is very short.86*87* @return the approximate accumulated collection elapsed time88* in milliseconds.89*/90public long getCollectionTime();919293}949596