11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6546089
27 * @summary Basic unit test of MemoryPoolMXBean.isUsageThresholdExceeded() and
28 * MemoryPoolMXBean.isCollectionThresholdExceeded().
29 * @author Mandy Chung
30 *
31 * @modules java.management
32 * @run main/othervm ThresholdTest
33 */
34
35 import java.lang.management.*;
36 import java.util.*;
37
38 public class ThresholdTest {
39 public static void main(String args[]) throws Exception {
40 long[] bigObject = new long[1000000];
41
42 System.gc(); // force an initial full-gc
43 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
44 try {
45 for (MemoryPoolMXBean p : pools) {
46 // verify if isUsageThresholdExceeded() returns correct value
47 checkUsageThreshold(p);
48 // verify if isCollectionUsageThresholdExceeded() returns correct value
49 checkCollectionUsageThreshold(p);
50 }
51 } finally {
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /*
25 * @test
26 * @bug 6546089
27 * @summary Basic unit test of MemoryPoolMXBean.isUsageThresholdExceeded() and
28 * MemoryPoolMXBean.isCollectionThresholdExceeded().
29 * @author Mandy Chung
30 *
31 * @run main/othervm ThresholdTest
32 */
33
34 import java.lang.management.*;
35 import java.util.*;
36
37 public class ThresholdTest {
38 public static void main(String args[]) throws Exception {
39 long[] bigObject = new long[1000000];
40
41 System.gc(); // force an initial full-gc
42 List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
43 try {
44 for (MemoryPoolMXBean p : pools) {
45 // verify if isUsageThresholdExceeded() returns correct value
46 checkUsageThreshold(p);
47 // verify if isCollectionUsageThresholdExceeded() returns correct value
48 checkCollectionUsageThreshold(p);
49 }
50 } finally {
|