Source Code Cross Referenced for MemoryPoolMXBean.java in  » 6.0-JDK-Core » lang » java » lang » management » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » lang » java.lang.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2003-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.lang.management;
027
028        /**
029         * The management interface for a memory pool.  A memory pool
030         * represents the memory resource managed by the Java virtual machine
031         * and is managed by one or more {@link MemoryManagerMXBean memory managers}.
032         *
033         * <p> A Java virtual machine has one or more instances of the 
034         * implementation class of this interface.  An instance 
035         * implementing this interface is 
036         * an <a href="ManagementFactory.html#MXBean">MXBean</a>
037         * that can be obtained by calling
038         * the {@link ManagementFactory#getMemoryPoolMXBeans} method or
039         * from the {@link ManagementFactory#getPlatformMBeanServer
040         * platform <tt>MBeanServer</tt>} method.
041         *
042         * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for
043         * a memory pool within an <tt>MBeanServer</tt> is:
044         * <blockquote>
045         *    {@link ManagementFactory#MEMORY_POOL_MXBEAN_DOMAIN_TYPE
046         *    <tt>java.lang:type=MemoryPool</tt>}<tt>,name=</tt><i>pool's name</i>
047         * </blockquote>
048         *
049         * <h4>Memory Type</h4>
050         * <p>The Java virtual machine has a heap for object allocation and also
051         * maintains non-heap memory for the method area and the Java virtual 
052         * machine execution.  The Java virtual machine can have one or more
053         * memory pools.  Each memory pool represents a memory area
054         * of one of the following types:
055         * <ul>
056         *   <li>{@link MemoryType#HEAP heap}</li> 
057         *   <li>{@link MemoryType#NON_HEAP non-heap}</li> 
058         * </ul>
059         *
060         * <h4>Memory Usage Monitoring</h4>
061         *
062         * A memory pool has the following attributes:
063         * <ul>
064         *   <li><a href="#Usage">Memory usage</a></li>
065         *   <li><a href="#PeakUsage">Peak memory usage</a></li>
066         *   <li><a href="#UsageThreshold">Usage Threshold</a></li>
067         *   <li><a href="#CollectionThreshold">Collection Usage Threshold</a>
068         *       (only supported by some <em>garbage-collected</em> memory pools)</li>
069         * </ul>
070         *
071         * <h4><a name="Usage">1. Memory Usage</a></h4>
072         *
073         * The {@link #getUsage} method provides an estimate
074         * of the current usage of a memory pool.
075         * For a garbage-collected memory pool, the amount of used memory 
076         * includes the memory occupied by all objects in the pool 
077         * including both <em>reachable</em> and <em>unreachable</em> objects. 
078         *
079         * <p>In general, this method is a lightweight operation for getting
080         * an approximate memory usage.  For some memory pools, for example, 
081         * when objects are not packed contiguously, this method may be
082         * an expensive operation that requires some computation to determine 
083         * the current memory usage.  An implementation should document when
084         * this is the case.
085         *
086         * <h4><a name="PeakUsage">2. Peak Memory Usage</a></h4>
087         *
088         * The Java virtual machine maintains the peak memory usage of a memory
089         * pool since the virtual machine was started or the peak was reset.
090         * The peak memory usage is returned by the {@link #getPeakUsage} method
091         * and reset by calling the {@link #resetPeakUsage} method.
092         *
093         * <h4><a name="UsageThreshold">3. Usage Threshold</a></h4>
094         * 
095         * Each memory pool has a manageable attribute 
096         * called the <i>usage threshold</i> which has a default value supplied
097         * by the Java virtual machine.  The default value is platform-dependent.
098         * The usage threshold can be set via the
099         * {@link #setUsageThreshold setUsageThreshold} method.
100         * If the threshold is set to a positive value, the usage threshold crossing
101         * checking is enabled in this memory pool. 
102         * If the usage threshold is set to zero, usage 
103         * threshold crossing checking on this memory pool is disabled.
104         * The {@link MemoryPoolMXBean#isUsageThresholdSupported} method can 
105         * be used to determine if this functionality is supported.
106         * <p>
107         * A Java virtual machine performs usage threshold crossing checking on a
108         * memory pool basis at its best appropriate time, typically, 
109         * at garbage collection time.
110         * Each memory pool maintains a {@link #getUsageThresholdCount 
111         * usage threshold count} that will get incremented 
112         * every time when the Java virtual machine 
113         * detects that the memory pool usage is crossing the threshold.
114         * <p>
115         * This manageable usage threshold attribute is designed for monitoring the
116         * increasing trend of memory usage with low overhead.
117         * Usage threshold may not be appropriate for some memory pools. 
118         * For example, a generational garbage collector, a common garbage collection
119         * algorithm used in many Java virtual machine implementations,
120         * manages two or more generations segregating objects by age.
121         * Most of the objects are allocated in 
122         * the <em>youngest generation</em> (say a nursery memory pool).  
123         * The nursery memory pool is designed to be filled up and 
124         * collecting the nursery memory pool will free most of its memory space
125         * since it is expected to contain mostly short-lived objects
126         * and mostly are unreachable at garbage collection time.
127         * In this case, it is more appropriate for the nursery memory pool
128         * not to support a usage threshold.  In addition,
129         * if the cost of an object allocation 
130         * in one memory pool is very low (for example, just atomic pointer exchange),
131         * the Java virtual machine would probably not support the usage threshold
132         * for that memory pool since the overhead in comparing the usage with 
133         * the threshold is higher than the cost of object allocation.
134         *
135         * <p>
136         * The memory usage of the system can be monitored using 
137         * <a href="#Polling">polling</a> or 
138         * <a href="#ThresholdNotification">threshold notification</a> mechanisms.
139         *
140         * <ol type="a">
141         *   <li><a name="Polling"><b>Polling</b></a>
142         *       <p>
143         *       An application can continuously monitor its memory usage
144         *       by calling either the {@link #getUsage} method for all
145         *       memory pools or the {@link #isUsageThresholdExceeded} method
146         *       for those memory pools that support a usage threshold.
147         *       Below is example code that has a thread delicated for
148         *       task distribution and processing.  At every interval, 
149         *       it will determine if it should receive and process new tasks based 
150         *       on its memory usage.  If the memory usage exceeds its usage threshold,
151         *       it will redistribute all outstanding tasks to other VMs and
152         *       stop receiving new tasks until the memory usage returns
153         *       below its usage threshold.
154         *
155         *       <pre>  
156         *       // Assume the usage threshold is supported for this pool.
157         *       // Set the threshold to myThreshold above which no new tasks
158         *       // should be taken.
159         *       pool.setUsageThreshold(myThreshold);
160         *       ....
161         *
162         *       boolean lowMemory = false;
163         *       while (true) {
164         *          if (pool.isUsageThresholdExceeded()) {
165         *              // potential low memory, so redistribute tasks to other VMs
166         *              lowMemory = true;
167         *              redistributeTasks();
168         *              // stop receiving new tasks
169         *              stopReceivingTasks();
170         *          } else {
171         *              if (lowMemory) {
172         *                  // resume receiving tasks
173         *                  lowMemory = false;
174         *                  resumeReceivingTasks();
175         *              } 
176         *              // processing outstanding task
177         *              ...
178         *          }
179         *          // sleep for sometime
180         *          try {
181         *              Thread.sleep(sometime);
182         *          } catch (InterruptedException e) {
183         *              ...
184         *          }
185         *       }
186         *       </pre>  
187         *
188         * <hr>
189         *       The above example does not differentiate the case where 
190         *       the memory usage has temporarily dropped below the usage threshold
191         *       from the case where the memory usage remains above the threshould
192         *       between two iterations.  The usage threshold count returned by
193         *       the {@link #getUsageThresholdCount} method
194         *       can be used to determine
195         *       if the memory usage has returned below the threshold
196         *       between two polls.
197         *       <p>
198         *       Below shows another example that takes some action if a 
199         *       memory pool is under low memory and ignores the memory usage
200         *       changes during the action processing time. 
201         *
202         *       <pre>
203         *       // Assume the usage threshold is supported for this pool.
204         *       // Set the threshold to myThreshold which determines if 
205         *       // the application will take some action under low memory condition.
206         *       pool.setUsageThreshold(myThreshold);
207         *
208         *       int prevCrossingCount = 0;
209         *       while (true) {
210         *           // A busy loop to detect when the memory usage  
211         *           // has exceeded the threshold.
212         *           while (!pool.isUsageThresholdExceeded() || 
213         *                  pool.getUsageThresholdCount() == prevCrossingCount) {
214         *               try {
215         *                   Thread.sleep(sometime)
216         *               } catch (InterruptException e) {
217         *                   ....
218         *               }
219         *           }
220         *
221         *           // Do some processing such as check for memory usage
222         *           // and issue a warning
223         *           ....
224         *
225         *           // Gets the current threshold count. The busy loop will then
226         *           // ignore any crossing of threshold happens during the processing.
227         *           prevCrossingCount = pool.getUsageThresholdCount();
228         *       }
229         *       </pre><hr>
230         *   </li>
231         *   <li><a name="ThresholdNotification"><b>Usage Threshold Notifications</b></a>
232         *       <p>
233         *       Usage threshold notification will be emitted by {@link MemoryMXBean}.
234         *       When the Java virtual machine detects that the memory usage of
235         *       a memory pool has reached or exceeded the usage threshold
236         *       the virtual machine will trigger the <tt>MemoryMXBean</tt> to emit an
237         *       {@link MemoryNotificationInfo#MEMORY_THRESHOLD_EXCEEDED
238         *       usage threshold exceeded notification}.
239         *       Another usage threshold exceeded notification will not be 
240         *       generated until the usage has fallen below the threshold and 
241         *       then exceeded it again.
242         *       <p>
243         *       Below is an example code implementing the same logic as the
244         *       first example above but using the usage threshold notification 
245         *       mechanism to detect low memory conditions instead of polling.
246         *       In this example code, upon receiving notification, the notification
247         *       listener notifies another thread to perform the actual action
248         *       such as to redistribute outstanding tasks, stop receiving tasks,
249         *       or resume receiving tasks.
250         *       The <tt>handleNotification</tt> method should be designed to
251         *       do a very minimal amount of work and return without delay to avoid 
252         *       causing delay in delivering subsequent notifications.  Time-consuming
253         *       actions should be performed by a separate thread.
254         *       The notification listener may be invoked by multiple threads 
255         *       concurrently; so the tasks performed by the listener
256         *       should be properly synchronized. 
257         *
258         *       <pre>  
259         *       class MyListener implements javax.management.NotificationListener {
260         *            public void handleNotification(Notification notification, Object handback)  {
261         *                String notifType = notification.getType();
262         *                if (notifType.equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
263         *                    // potential low memory, notify another thread
264         *                    // to redistribute outstanding tasks to other VMs
265         *                    // and stop receiving new tasks.
266         *                    lowMemory = true;
267         *                    notifyAnotherThread(lowMemory);
268         *                }
269         *            }
270         *       }
271         *
272         *       // Register MyListener with MemoryMXBean  
273         *       MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
274         *       NotificationEmitter emitter = (NotificationEmitter) mbean;
275         *       MyListener listener = new MyListener();
276         *       emitter.addNotificationListener(listener, null, null);
277         *
278         *       // Assume this pool supports a usage threshold.
279         *       // Set the threshold to myThreshold above which no new tasks
280         *       // should be taken.
281         *       pool.setUsageThreshold(myThreshold);
282         *       
283         *       // Usage threshold detection is enabled and notification will be 
284         *       // handled by MyListener.  Continue for other processing.
285         *       ....
286         *
287         *       </pre>  
288         * <hr>
289         *       <p>
290         *       There is no guarantee about when the <tt>MemoryMXBean</tt> will emit
291         *       a threshold notification and when the notification will be delivered.
292         *       When a notification listener is invoked, the memory usage of 
293         *       the memory pool may have crossed the usage threshold more
294         *       than once.
295         *       The {@link MemoryNotificationInfo#getCount} method returns the number
296         *       of times that the memory usage has crossed the usage threshold
297         *       at the point in time when the notification was constructed.
298         *       It can be compared with the current usage threshold count returned
299         *       by the {@link #getUsageThresholdCount} method to determine if 
300         *       such situation has occurred.
301         *   </li>
302         * </ol>
303         *
304         * <h4><a name="CollectionThreshold">4. Collection Usage Threshold</a></h4>
305         * 
306         * Collection usage threshold is a manageable attribute only applicable
307         * to some garbage-collected memory pools.
308         * After a Java virtual machine has expended effort in reclaiming memory
309         * space by recycling unused objects in a memory pool at garbage collection
310         * time, some number of bytes in the memory pools that are garbaged 
311         * collected will still be in use.  The collection usage threshold 
312         * allows a value to be set for this number of bytes such
313         * that if the threshold is exceeded, 
314         * a {@link MemoryNotificationInfo#MEMORY_THRESHOLD_EXCEEDED
315         * collection usage threshold exceeded notification}
316         * will be emitted by the {@link MemoryMXBean}. 
317         * In addition, the {@link #getCollectionUsageThresholdCount
318         * collection usage threshold count} will then be incremented.
319         *
320         * <p>
321         * The {@link MemoryPoolMXBean#isCollectionUsageThresholdSupported} method can 
322         * be used to determine if this functionality is supported.
323         *
324         * <p>
325         * A Java virtual machine performs collection usage threshold checking
326         * on a memory pool basis.  This checking is enabled if the collection
327         * usage threshold is set to a positive value.
328         * If the collection usage threshold is set to zero, this checking 
329         * is disabled on this memory pool.  Default value is zero.
330         * The Java virtual machine performs the collection usage threshold 
331         * checking at garbage collection time.
332         *
333         * <p>
334         * Some garbage-collected memory pools may
335         * choose not to support the collection usage threshold.  For example,
336         * a memory pool is only managed by a continuous concurrent garbage
337         * collector.  Objects can be allocated in this memory pool by some thread
338         * while the unused objects are reclaimed by the concurrent garbage
339         * collector simultaneously.  Unless there is a well-defined 
340         * garbage collection time which is the best appropriate time
341         * to check the memory usage, the collection usage threshold should not
342         * be supported.
343         *
344         * <p>
345         * The collection usage threshold is designed for monitoring the memory usage 
346         * after the Java virtual machine has expended effort in reclaiming 
347         * memory space.  The collection usage could also be monitored 
348         * by the polling and threshold notification mechanism 
349         * described above for the <a href="#UsageThreshold">usage threshold</a>
350         * in a similar fashion.
351         *
352         * @see <a href="../../../javax/management/package-summary.html">
353         *      JMX Specification.</a>
354         * @see <a href="package-summary.html#examples">
355         *      Ways to Access MXBeans</a>
356         *
357         * @author  Mandy Chung
358         * @version 1.28, 05/05/07 
359         * @since   1.5
360         */
361        public interface MemoryPoolMXBean {
362            /**
363             * Returns the name representing this memory pool.
364             *
365             * @return the name of this memory pool.
366             */
367            public String getName();
368
369            /**
370             * Returns the type of this memory pool.
371             *
372             * <p>
373             * <b>MBeanServer access</b>:<br>
374             * The mapped type of <tt>MemoryType</tt> is <tt>String</tt>
375             * and the value is the name of the <tt>MemoryType</tt>.
376             *
377             * @return the type of this memory pool.
378             */
379            public MemoryType getType();
380
381            /**
382             * Returns an estimate of the memory usage of this memory pool.
383             * This method returns <tt>null</tt>
384             * if this memory pool is not valid (i.e. no longer exists).
385             *
386             * <p>
387             * This method requests the Java virtual machine to make
388             * a best-effort estimate of the current memory usage of this
389             * memory pool. For some memory pools, this method may be an
390             * expensive operation that requires some computation to determine
391             * the estimate.  An implementation should document when
392             * this is the case.
393             *
394             * <p>This method is designed for use in monitoring system
395             * memory usage and detecting low memory condition.
396             *
397             * <p>
398             * <b>MBeanServer access</b>:<br>
399             * The mapped type of <tt>MemoryUsage</tt> is
400             * <tt>CompositeData</tt> with attributes as specified in
401             * {@link MemoryUsage#from MemoryUsage}.
402             *
403             * @return a {@link MemoryUsage} object; or <tt>null</tt> if 
404             * this pool not valid.
405             */
406            public MemoryUsage getUsage();
407
408            /**
409             * Returns the peak memory usage of this memory pool since the
410             * Java virtual machine was started or since the peak was reset.
411             * This method returns <tt>null</tt>
412             * if this memory pool is not valid (i.e. no longer exists).
413             *
414             * <p>
415             * <b>MBeanServer access</b>:<br>
416             * The mapped type of <tt>MemoryUsage</tt> is
417             * <tt>CompositeData</tt> with attributes as specified in
418             * {@link MemoryUsage#from MemoryUsage}.
419             *
420             * @return a {@link MemoryUsage} object representing the peak
421             * memory usage; or <tt>null</tt> if this pool is not valid.
422             *
423             */
424            public MemoryUsage getPeakUsage();
425
426            /**
427             * Resets the peak memory usage statistic of this memory pool
428             * to the current memory usage.
429             *
430             * @throws java.lang.SecurityException if a security manager
431             *         exists and the caller does not have
432             *         ManagementPermission("control").
433             */
434            public void resetPeakUsage();
435
436            /**
437             * Tests if this memory pool is valid in the Java virtual
438             * machine.  A memory pool becomes invalid once the Java virtual
439             * machine removes it from the memory system.
440             *
441             * @return <tt>true</tt> if the memory pool is valid in the running 
442             *              Java virtual machine;
443             *         <tt>false</tt> otherwise.
444             */
445            public boolean isValid();
446
447            /**
448             * Returns the name of memory managers that manages this memory pool.
449             * Each memory pool will be managed by at least one memory manager.
450             *
451             * @return an array of <tt>String</tt> objects, each is the name of
452             * a memory manager managing this memory pool.
453             */
454            public String[] getMemoryManagerNames();
455
456            /**
457             * Returns the usage threshold value of this memory pool in bytes.
458             * Each memory pool has a platform-dependent default threshold value.
459             * The current usage threshold can be changed via the
460             * {@link #setUsageThreshold setUsageThreshold} method.
461             *
462             * @return the usage threshold value of this memory pool in bytes.
463             *
464             * @throws UnsupportedOperationException if this memory pool
465             *         does not support a usage threshold.
466             *
467             * @see #isUsageThresholdSupported
468             */
469            public long getUsageThreshold();
470
471            /**
472             * Sets the threshold of this memory pool to the given <tt>threshold</tt>
473             * value if this memory pool supports the usage threshold. 
474             * The usage threshold crossing checking is enabled in this memory pool 
475             * if the threshold is set to a positive value.
476             * The usage threshold crossing checking is disabled
477             * if it is set to zero. 
478             *
479             * @param threshold the new threshold value in bytes. Must be non-negative.
480             *
481             * @throws IllegalArgumentException if <tt>threshold</tt> is negative
482             *         or greater than the maximum amount of memory for
483             *         this memory pool if defined.
484             *
485             * @throws UnsupportedOperationException if this memory pool
486             *         does not support a usage threshold.
487             *
488             * @throws java.lang.SecurityException if a security manager
489             *         exists and the caller does not have
490             *         ManagementPermission("control").
491             *
492             * @see #isUsageThresholdSupported
493             * @see <a href="#UsageThreshold">Usage threshold</a>
494             */
495            public void setUsageThreshold(long threshold);
496
497            /**
498             * Tests if the memory usage of this memory pool
499             * reaches or exceeds its usage threshold value.
500             *
501             * @return <tt>true</tt> if the memory usage of
502             * this memory pool reaches or exceeds the threshold value;
503             * <tt>false</tt> otherwise.
504             *
505             * @throws UnsupportedOperationException if this memory pool
506             *         does not support a usage threshold.
507             */
508            public boolean isUsageThresholdExceeded();
509
510            /**
511             * Returns the number of times that the memory usage has crossed
512             * the usage threshold.
513             *
514             * @return the number of times that the memory usage 
515             * has crossed its usage threshold value.
516             *
517             * @throws UnsupportedOperationException if this memory pool
518             * does not support a usage threshold.
519             */
520            public long getUsageThresholdCount();
521
522            /**
523             * Tests if this memory pool supports usage threshold.
524             *
525             * @return <tt>true</tt> if this memory pool supports usage threshold; 
526             * <tt>false</tt> otherwise.
527             */
528            public boolean isUsageThresholdSupported();
529
530            /**
531             * Returns the collection usage threshold value of this memory pool 
532             * in bytes.  The default value is zero. The collection usage 
533             * threshold can be changed via the 
534             * {@link #setCollectionUsageThreshold setCollectionUsageThreshold} method.
535             * 
536             * @return the collection usage threshold of this memory pool in bytes.
537             *
538             * @throws UnsupportedOperationException if this memory pool
539             *         does not support a collection usage threshold.
540             *
541             * @see #isCollectionUsageThresholdSupported
542             */
543            public long getCollectionUsageThreshold();
544
545            /**
546             * Sets the collection usage threshold of this memory pool to 
547             * the given <tt>threshold</tt> value. 
548             * When this threshold is set to positive, the Java virtual machine
549             * will check the memory usage at its best appropriate time after it has 
550             * expended effort in recycling unused objects in this memory pool.
551             * <p>
552             * The collection usage threshold crossing checking is enabled 
553             * in this memory pool if the threshold is set to a positive value.
554             * The collection usage threshold crossing checking is disabled
555             * if it is set to zero. 
556             * 
557             * @param threshold the new collection usage threshold value in bytes.
558             *              Must be non-negative.
559             *
560             * @throws IllegalArgumentException if <tt>threshold</tt> is negative
561             *         or greater than the maximum amount of memory for 
562             *         this memory pool if defined.
563             *
564             * @throws UnsupportedOperationException if this memory pool
565             *         does not support a collection usage threshold.
566             *
567             * @throws java.lang.SecurityException if a security manager
568             *         exists and the caller does not have
569             *         ManagementPermission("control").
570             *
571             * @see #isCollectionUsageThresholdSupported
572             * @see <a href="#CollectionThreshold">Collection usage threshold</a>
573             */
574            public void setCollectionUsageThreshold(long threshold);
575
576            /**
577             * Tests if the memory usage of this memory pool after
578             * the most recent collection on which the Java virtual
579             * machine has expended effort has reached or
580             * exceeded its collection usage threshold. 
581             * This method does not request the Java virtual
582             * machine to perform any garbage collection other than its normal
583             * automatic memory management.
584             *
585             * @return <tt>true</tt> if the memory usage of this memory pool 
586             * reaches or exceeds the collection usage threshold value
587             * in the most recent collection;
588             * <tt>false</tt> otherwise.
589             *
590             * @throws UnsupportedOperationException if this memory pool
591             *         does not support a usage threshold.
592             */
593            public boolean isCollectionUsageThresholdExceeded();
594
595            /**
596             * Returns the number of times that the Java virtual machine
597             * has detected that the memory usage has reached or 
598             * exceeded the collection usage threshold.
599             *
600             * @return the number of times that the memory 
601             * usage has reached or exceeded the collection usage threshold.
602             *
603             * @throws UnsupportedOperationException if this memory pool
604             *         does not support a collection usage threshold.
605             *
606             * @see #isCollectionUsageThresholdSupported
607             */
608            public long getCollectionUsageThresholdCount();
609
610            /**
611             * Returns the memory usage after the Java virtual machine  
612             * most recently expended effort in recycling unused objects
613             * in this memory pool.
614             * This method does not request the Java virtual
615             * machine to perform any garbage collection other than its normal
616             * automatic memory management.
617             * This method returns <tt>null</tt> if the Java virtual
618             * machine does not support this method.
619             * 
620             * <p>
621             * <b>MBeanServer access</b>:<br>
622             * The mapped type of <tt>MemoryUsage</tt> is
623             * <tt>CompositeData</tt> with attributes as specified in
624             * {@link MemoryUsage#from MemoryUsage}.
625             *
626             * @return a {@link MemoryUsage} representing the memory usage of
627             * this memory pool after the Java virtual machine most recently 
628             * expended effort in recycling unused objects;
629             * <tt>null</tt> if this method is not supported.
630             */
631            public MemoryUsage getCollectionUsage();
632
633            /**
634             * Tests if this memory pool supports a collection usage threshold.
635             *
636             * @return <tt>true</tt> if this memory pool supports the
637             * collection usage threshold; <tt>false</tt> otherwise.
638             */
639            public boolean isCollectionUsageThresholdSupported();
640        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.