1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 4530538 6980984
27 * @summary Basic unit test of memory management testing:
28 * 1) setUsageThreshold() and getUsageThreshold()
29 * 2) test low memory detection on the old generation.
30 *
31 * @author Mandy Chung
32 *
33 * @build MemoryManagement MemoryUtil
34 * @run main/othervm/timeout=600 -Xmn8m -XX:+IgnoreUnrecognizedVMOptions -XX:G1HeapRegionSize=1 -XX:-UseLargePages MemoryManagement
35 */
36
37 import java.lang.management.*;
38 import java.util.*;
39 import javax.management.*;
40 import javax.management.openmbean.CompositeData;
41
42 public class MemoryManagement {
43 private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
44 private static final List pools =
45 Collections.synchronizedList(ManagementFactory.getMemoryPoolMXBeans());
46 private static final List managers =
47 Collections.synchronizedList(ManagementFactory.getMemoryManagerMXBeans());
48 private static volatile MemoryPoolMXBean mpool = null;
49 private static volatile boolean trace = false;
50 private static volatile boolean testFailed = false;
51 private static final int NUM_CHUNKS = 2;
52 // Must match -Xmn set on the @run line
|
1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 4530538 6980984
27 * @summary Basic unit test of memory management testing:
28 * 1) setUsageThreshold() and getUsageThreshold()
29 * 2) test low memory detection on the old generation.
30 *
31 * @author Mandy Chung
32 *
33 * @modules java.management
34 * @build MemoryManagement MemoryUtil
35 * @run main/othervm/timeout=600 -Xmn8m -XX:+IgnoreUnrecognizedVMOptions -XX:G1HeapRegionSize=1 -XX:-UseLargePages MemoryManagement
36 */
37
38 import java.lang.management.*;
39 import java.util.*;
40 import javax.management.*;
41 import javax.management.openmbean.CompositeData;
42
43 public class MemoryManagement {
44 private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
45 private static final List pools =
46 Collections.synchronizedList(ManagementFactory.getMemoryPoolMXBeans());
47 private static final List managers =
48 Collections.synchronizedList(ManagementFactory.getMemoryManagerMXBeans());
49 private static volatile MemoryPoolMXBean mpool = null;
50 private static volatile boolean trace = false;
51 private static volatile boolean testFailed = false;
52 private static final int NUM_CHUNKS = 2;
53 // Must match -Xmn set on the @run line
|