1 |
756 |
jeremybenn |
/* MemoryPoolMXBeanImpl.java - VM interface for memory pool beans
|
2 |
|
|
Copyright (C) 2006 Free Software Foundation
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
package gnu.java.lang.management;
|
39 |
|
|
|
40 |
|
|
import java.lang.management.MemoryUsage;
|
41 |
|
|
|
42 |
|
|
/**
|
43 |
|
|
* Provides access to information on the memory resources or
|
44 |
|
|
* pools used by the current invocation of the virtual machine.
|
45 |
|
|
*
|
46 |
|
|
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
47 |
|
|
* @since 1.5
|
48 |
|
|
*/
|
49 |
|
|
final class VMMemoryPoolMXBeanImpl
|
50 |
|
|
{
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
* Returns memory usage statistics for the specified pool
|
54 |
|
|
* just after a best-effort attempt to free memory. This
|
55 |
|
|
* is valid only for certain garbage collectors.
|
56 |
|
|
*
|
57 |
|
|
* @param name the name of the pool to obtain statistics on.
|
58 |
|
|
* @return a {@link java.lang.management.MemoryUsage} object
|
59 |
|
|
* containing the statistics or <code>null</code>
|
60 |
|
|
* if this pool does not support such statistics.
|
61 |
|
|
*/
|
62 |
|
|
static native MemoryUsage getCollectionUsage(String name);
|
63 |
|
|
|
64 |
|
|
/**
|
65 |
|
|
* Returns the collection usage threshold for the specified pool.
|
66 |
|
|
* This is only called if this functionality is supported
|
67 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
68 |
|
|
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
69 |
|
|
* is defined). The value is initially zero.
|
70 |
|
|
*
|
71 |
|
|
* @param name the name of the pool to obtain statistics on.
|
72 |
|
|
* @return the collection usage threshold.
|
73 |
|
|
*/
|
74 |
|
|
static native long getCollectionUsageThreshold(String name);
|
75 |
|
|
|
76 |
|
|
/**
|
77 |
|
|
* Returns the number of times the collection usage threshold
|
78 |
|
|
* has been met or exceeded by the specified pool.
|
79 |
|
|
* This is only called if this functionality is supported
|
80 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
81 |
|
|
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
82 |
|
|
* is defined).
|
83 |
|
|
*
|
84 |
|
|
* @param name the name of the pool to obtain statistics on.
|
85 |
|
|
* @return the collection usage threshold count.
|
86 |
|
|
*/
|
87 |
|
|
static native long getCollectionUsageThresholdCount(String name);
|
88 |
|
|
|
89 |
|
|
/**
|
90 |
|
|
* Returns an array of names of memory managers which manage
|
91 |
|
|
* the specified pool.
|
92 |
|
|
*
|
93 |
|
|
* @param name the name of the pool to obtain statistics on.
|
94 |
|
|
* @return a list of memory managers for the pool.
|
95 |
|
|
*/
|
96 |
|
|
static native String[] getMemoryManagerNames(String name);
|
97 |
|
|
|
98 |
|
|
/**
|
99 |
|
|
* Returns the peak usage level of the specified pool.
|
100 |
|
|
* This is only called if the pool is valid.
|
101 |
|
|
*
|
102 |
|
|
* @param name the name of the pool to obtain statistics on.
|
103 |
|
|
* @return a {@link java.lang.management.MemoryUsage} object
|
104 |
|
|
* containing the statistics.
|
105 |
|
|
*/
|
106 |
|
|
static native MemoryUsage getPeakUsage(String name);
|
107 |
|
|
|
108 |
|
|
/**
|
109 |
|
|
* Returns the type of memory used by the specified pool.
|
110 |
|
|
* The value must be either "HEAP" or "NON_HEAP".
|
111 |
|
|
*
|
112 |
|
|
* @param name the name of the pool to obtain statistics on.
|
113 |
|
|
* @return the type of the given pool.
|
114 |
|
|
*/
|
115 |
|
|
static native String getType(String name);
|
116 |
|
|
|
117 |
|
|
/**
|
118 |
|
|
* Returns the current usage level of the specified pool.
|
119 |
|
|
* This is only called if the pool is valid.
|
120 |
|
|
*
|
121 |
|
|
* @param name the name of the pool to obtain statistics on.
|
122 |
|
|
* @return a {@link java.lang.management.MemoryUsage} object
|
123 |
|
|
* containing the statistics.
|
124 |
|
|
*/
|
125 |
|
|
static native MemoryUsage getUsage(String name);
|
126 |
|
|
|
127 |
|
|
/**
|
128 |
|
|
* Returns the usage threshold for the specified pool.
|
129 |
|
|
* This is only called if this functionality is supported
|
130 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
131 |
|
|
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
132 |
|
|
* is defined). The value is initially defined by the
|
133 |
|
|
* virtual machine.
|
134 |
|
|
*
|
135 |
|
|
* @param name the name of the pool to obtain statistics on.
|
136 |
|
|
* @return the usage threshold.
|
137 |
|
|
*/
|
138 |
|
|
static native long getUsageThreshold(String name);
|
139 |
|
|
|
140 |
|
|
/**
|
141 |
|
|
* Returns the number of times the usage threshold
|
142 |
|
|
* has been met or exceeded by the specified pool.
|
143 |
|
|
* This is only called if this functionality is supported
|
144 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
145 |
|
|
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
146 |
|
|
* is defined).
|
147 |
|
|
*
|
148 |
|
|
* @param name the name of the pool to obtain statistics on.
|
149 |
|
|
* @return the usage threshold count.
|
150 |
|
|
*/
|
151 |
|
|
static native long getUsageThresholdCount(String name);
|
152 |
|
|
|
153 |
|
|
/**
|
154 |
|
|
* Returns true if the specified pool is still valid i.e.
|
155 |
|
|
* it is still in use by the virtual machine.
|
156 |
|
|
*
|
157 |
|
|
* @param name the name of the pool to check the validity of.
|
158 |
|
|
* @return true if the pool is valid.
|
159 |
|
|
*/
|
160 |
|
|
static native boolean isValid(String name);
|
161 |
|
|
|
162 |
|
|
/**
|
163 |
|
|
* Resets the peak usage level to the current usage level for
|
164 |
|
|
* the specified pool.
|
165 |
|
|
*
|
166 |
|
|
* @param name the name of the pool to reset the peak usage of.
|
167 |
|
|
*/
|
168 |
|
|
static native void resetPeakUsage(String name);
|
169 |
|
|
|
170 |
|
|
/**
|
171 |
|
|
* Sets the collection usage threshold for the specified
|
172 |
|
|
* pool to the supplied value.
|
173 |
|
|
* This is only called if this functionality is supported
|
174 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
175 |
|
|
* <code>gnu.java.lang.management.CollectionUsageThresholdSupport</code>,
|
176 |
|
|
* is defined).
|
177 |
|
|
*
|
178 |
|
|
* @param name the name of the pool to set the threshold of.
|
179 |
|
|
* @param threshold the new threshold level.
|
180 |
|
|
*/
|
181 |
|
|
static native void setCollectionUsageThreshold(String name, long threshold);
|
182 |
|
|
|
183 |
|
|
/**
|
184 |
|
|
* Sets the usage threshold for the specified pool to the supplied value.
|
185 |
|
|
* This is only called if this functionality is supported
|
186 |
|
|
* by the virtual machine (i.e. the appropriate property,
|
187 |
|
|
* <code>gnu.java.lang.management.UsageThresholdSupport</code>,
|
188 |
|
|
* is defined).
|
189 |
|
|
*
|
190 |
|
|
* @param name the name of the pool to set the threshold of.
|
191 |
|
|
* @param threshold the new threshold level.
|
192 |
|
|
*/
|
193 |
|
|
static native void setUsageThreshold(String name, long threshold);
|
194 |
|
|
|
195 |
|
|
}
|