< prev index next >

test/gc/metaspace/TestPerfCountersAndMemoryPools.java

Print this page




  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 import java.util.List;
  25 import java.lang.management.*;
  26 
  27 import com.oracle.java.testlibrary.*;
  28 import static com.oracle.java.testlibrary.Asserts.*;
  29 
  30 /* @test TestPerfCountersAndMemoryPools
  31  * @bug 8023476
  32  * @library /testlibrary

  33  * @requires vm.gc=="Serial" | vm.gc=="null"
  34  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
  35  *          report the same data.
  36  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
  37  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
  38  */
  39 public class TestPerfCountersAndMemoryPools {
  40     public static void main(String[] args) throws Exception {
  41         checkMemoryUsage("Metaspace", "sun.gc.metaspace");
  42 
  43         if (InputArguments.contains("-XX:+UseCompressedKlassPointers") && Platform.is64bit()) {
  44             checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace");
  45         }
  46     }
  47 
  48     private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
  49         List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
  50         for (MemoryPoolMXBean pool : pools) {
  51             if (pool.getName().equals(memoryPoolName)) {
  52                 return pool;




  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 import java.util.List;
  25 import java.lang.management.*;
  26 
  27 import com.oracle.java.testlibrary.*;
  28 import static com.oracle.java.testlibrary.Asserts.*;
  29 
  30 /* @test TestPerfCountersAndMemoryPools
  31  * @bug 8023476
  32  * @library /testlibrary
  33  * @build com.oracle.java.testlibrary.*
  34  * @requires vm.gc=="Serial" | vm.gc=="null"
  35  * @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
  36  *          report the same data.
  37  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
  38  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
  39  */
  40 public class TestPerfCountersAndMemoryPools {
  41     public static void main(String[] args) throws Exception {
  42         checkMemoryUsage("Metaspace", "sun.gc.metaspace");
  43 
  44         if (InputArguments.contains("-XX:+UseCompressedKlassPointers") && Platform.is64bit()) {
  45             checkMemoryUsage("Compressed Class Space", "sun.gc.compressedclassspace");
  46         }
  47     }
  48 
  49     private static MemoryPoolMXBean getMemoryPool(String memoryPoolName) {
  50         List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
  51         for (MemoryPoolMXBean pool : pools) {
  52             if (pool.getName().equals(memoryPoolName)) {
  53                 return pool;


< prev index next >