hotspot/test/gc/g1/TestPrintGCDetails.java
author johnc
Thu, 16 May 2013 09:24:26 -0700
changeset 17396 4d281f3a57bf
child 29678 dd2f3932c21e
permissions -rw-r--r--
8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info Summary: Include metaspace information (used, allocated, reserved) in the PrintGCDetails output for full GCs. Reviewed-by: poonam, jmasa, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17396
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     1
/*
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     4
 *
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     8
 *
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    13
 * accompanied this code).
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    14
 *
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    18
 *
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    21
 * questions.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    22
 */
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    23
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    24
/*
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    25
 * @test TestPrintGCDetails
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    26
 * @bug 8010738
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    27
 * @summary Ensure that the PrintGCDetails for a full GC with G1 includes Metaspace.
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    28
 * @key gc
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    29
 * @key regression
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    30
 * @library /testlibrary
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    31
 */
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    32
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    33
import com.oracle.java.testlibrary.ProcessTools;
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    34
import com.oracle.java.testlibrary.OutputAnalyzer;
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    35
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    36
public class TestPrintGCDetails {
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    37
  public static void main(String[] args) throws Exception {
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    38
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    39
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    40
                                                              "-XX:+PrintGCDetails",
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    41
                                                              SystemGCTest.class.getName());
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    42
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    43
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    44
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    45
    System.out.println("Output:\n" + output.getOutput());
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    46
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    47
    output.shouldContain("Metaspace");
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    48
    output.shouldHaveExitValue(0);
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    49
  }
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    50
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    51
  static class SystemGCTest {
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    52
    public static void main(String [] args) {
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    53
      System.out.println("Calling System.gc()");
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    54
      System.gc();
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    55
    }
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    56
  }
4d281f3a57bf 8010738: G1: Output for full GCs with +PrintGCDetails should contain perm gen size/meta data change info
johnc
parents:
diff changeset
    57
}