GC.java revision 0
869N/A * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved. 869N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 869N/A * This code is free software; you can redistribute it and/or modify it 869N/A * under the terms of the GNU General Public License version 2 only, as 869N/A * published by the Free Software Foundation. Sun designates this 869N/A * particular file as subject to the "Classpath" exception as provided 869N/A * by Sun in the LICENSE file that accompanied this code. 869N/A * This code is distributed in the hope that it will be useful, but WITHOUT 869N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 869N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 869N/A * version 2 for more details (a copy is included in the LICENSE file that 869N/A * accompanied this code). 869N/A * You should have received a copy of the GNU General Public License version 873N/A * 2 along with this work; if not, write to the Free Software Foundation, 869N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 869N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 869N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * Support for garbage-collection latency requests. 0N/A * @author Mark Reinhold 48N/A private GC() { }
/* To prevent instantiation */ 869N/A /* Latency-target value indicating that there's no active target 0N/A /* The current latency target, or NO_TARGET if there is no target 1004N/A /* The daemon thread that implements the latency-target mechanism, 1007N/A * or null if there is presently no daemon thread 869N/A /* The lock object for the latencyTarget and daemon fields. The daemon 869N/A * thread, if it exists, waits on this lock for notification that the 1004N/A * latency target has changed. 65N/A * Returns the maximum <em>object-inspection age</em>, which is the number 869N/A * of real-time milliseconds that have elapsed since the 868N/A * least-recently-inspected heap object was last inspected by the garbage 65N/A * <p> For simple stop-the-world collectors this value is just the time 65N/A * since the most recent collection. For generational collectors it is the 65N/A * time since the oldest generation was most recently collected. Other 65N/A * collectors are free to return a pessimistic estimate of the elapsed 65N/A * time, or simply the time since the last full collection was performed. 65N/A * <p> Note that in the presence of reference objects, a given object that 65N/A * is no longer strongly reachable may have to be inspected multiple times 65N/A * before it can be reclaimed. 0N/A /* No latency target, so exit */ 868N/A /* Do a full collection. There is a remote possibility 0N/A * that a full collection will occurr between the time 0N/A * we sample the inspection age and the time the GC 869N/A * actually starts, but this is sufficiently unlikely 0N/A * that it doesn't seem worth the more expensive JVM 0N/A * interface that would be required. 868N/A /* Wait for the latency period to expire, 869N/A * or for notification that the period has changed 1155N/A /* Create a new daemon thread in the root thread group */ 869N/A /* Sets the latency target to the given value. 868N/A * Must be invoked while holding the lock. 869N/A /* Create a new daemon thread */ 0N/A /* Notify the existing daemon thread 868N/A * that the lateency target has changed 868N/A * Represents an active garbage-collection latency request. Instances of 868N/A * this class are created by the <code>{@link #requestLatency}</code> 868N/A * method. Given a request, the only interesting operation is that of 868N/A /* Instance counter, used to generate unique identifers */ 868N/A /* Sorted set of active latency requests */ 868N/A /* Examine the request set and reset the latency target if necessary. 868N/A * Must be invoked while holding the lock. 868N/A /* The requested latency, or NO_TARGET 868N/A * if this request has been cancelled 868N/A /* Unique identifier for this request */ 868N/A * Cancels this latency request. 869N/A * @throws IllegalStateException 869N/A * If this request has already been cancelled 869N/A +
this +
" not found");
869N/A return (d <
0) ? -
1 : ((d >
0) ? +
1 :
0);
869N/A * Makes a new request for a garbage-collection latency of the given 869N/A * number of real-time milliseconds. A low-priority daemon thread makes a 869N/A * best effort to ensure that the maximum object-inspection age never 869N/A * exceeds the smallest of the currently active requests. 869N/A * The requested latency 869N/A * @throws IllegalArgumentException 869N/A * If the given <code>latency</code> is non-positive 869N/A * Returns the current smallest garbage-collection latency request, or zero 868N/A * if there are no active requests.