hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java
author brutisso
Thu, 10 Dec 2015 14:57:55 +0100
changeset 35061 be6025ebffea
parent 30604 b8d532cb6420
child 35866 92d36ce7897d
permissions -rw-r--r--
8145092: Use Unified Logging for the GC logging Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     1
/*
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28379
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     4
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     8
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    14
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    18
 *
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    21
 * questions.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    22
 */
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    23
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    24
/*
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    25
 * @test TestG1TraceEagerReclaimHumongousObjects
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    26
 * @bug 8058801 8048179
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    27
 * @summary Ensure that the output for a G1TraceEagerReclaimHumongousObjects
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    28
 * includes the expected necessary messages.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    29
 * @key gc
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    30
 * @library /testlibrary
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28379
diff changeset
    31
 * @modules java.base/sun.misc
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28379
diff changeset
    32
 *          java.management
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    33
 */
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    34
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    35
import jdk.test.lib.ProcessTools;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 29678
diff changeset
    36
import jdk.test.lib.OutputAnalyzer;
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    37
import java.util.LinkedList;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    38
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    39
public class TestG1TraceEagerReclaimHumongousObjects {
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    40
  public static void main(String[] args) throws Exception {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    41
    testGCLogs();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    42
    testHumongousObjectGCLogs();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    43
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    44
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    45
  private static void testGCLogs() throws Exception {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    46
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    47
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    48
                                               "-Xms128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    49
                                               "-Xmx128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    50
                                               "-Xmn16M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    51
                                               "-XX:G1HeapRegionSize=1M",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    52
                                               "-Xlog:gc+phases=trace",
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    53
                                               "-XX:+UnlockExperimentalVMOptions",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    54
                                               GCTest.class.getName());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    55
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    56
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    57
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    58
    // As G1EagerReclaimHumongousObjects is set(default), below logs should be displayed.
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    59
    // And GCTest doesn't have humongous objects, so values should be zero.
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    60
    output.shouldContain("Humongous Reclaim");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    61
    output.shouldContain("Humongous Total: 0");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    62
    output.shouldContain("Humongous Candidate: 0");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    63
    output.shouldContain("Humongous Reclaimed: 0");
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    64
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    65
    output.shouldHaveExitValue(0);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    66
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    67
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    68
  private static void testHumongousObjectGCLogs() throws Exception {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    69
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    70
                                               "-Xms128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    71
                                               "-Xmx128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    72
                                               "-Xmn16M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    73
                                               "-XX:G1HeapRegionSize=1M",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    74
                                               "-Xlog:gc+phases=trace,gc+humongous=trace",
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    75
                                               "-XX:+UnlockExperimentalVMOptions",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    76
                                               GCWithHumongousObjectTest.class.getName());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    77
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    78
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    79
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    80
    // As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    81
    output.shouldContain("Humongous Reclaim");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    82
    output.shouldContain("Humongous Total");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    83
    output.shouldContain("Humongous Candidate");
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 30604
diff changeset
    84
    output.shouldContain("Humongous Reclaimed");
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    85
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    86
    // As G1TraceReclaimDeadHumongousObjectsAtYoungGC is set and GCWithHumongousObjectTest has humongous objects,
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    87
    // these logs should be displayed.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    88
    output.shouldContain("Live humongous");
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    89
    output.shouldContain("Dead humongous region");
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    90
    output.shouldHaveExitValue(0);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    91
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    92
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    93
  static class GCTest {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    94
    private static byte[] garbage;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    95
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    96
    public static void main(String [] args) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    97
      System.out.println("Creating garbage");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    98
      // create 128MB of garbage. This should result in at least one GC
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    99
      for (int i = 0; i < 1024; i++) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   100
        garbage = new byte[128 * 1024];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   101
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   102
      System.out.println("Done");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   103
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   104
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   105
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   106
  static class GCWithHumongousObjectTest {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   107
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   108
    public static final int M = 1024*1024;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   109
    public static LinkedList<Object> garbageList = new LinkedList<Object>();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   110
    // A large object referenced by a static.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   111
    static int[] filler = new int[10 * M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   112
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   113
    public static void genGarbage() {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   114
      for (int i = 0; i < 32*1024; i++) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   115
        garbageList.add(new int[100]);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   116
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   117
      garbageList.clear();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   118
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   119
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   120
    public static void main(String[] args) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   121
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   122
      int[] large = new int[M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   123
      Object ref = large;
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   124
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   125
      System.out.println("Creating garbage");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   126
      for (int i = 0; i < 100; i++) {
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   127
        // A large object that will be reclaimed eagerly.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   128
        large = new int[6*M];
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   129
        genGarbage();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   130
        // Make sure that the compiler cannot completely remove
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   131
        // the allocation of the large object until here.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   132
        System.out.println(large);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   133
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   134
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   135
      // Keep the reference to the first object alive.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   136
      System.out.println(ref);
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   137
      System.out.println("Done");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   138
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   139
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   140
}