hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java
author ykantser
Mon, 04 May 2015 16:30:07 +0200
changeset 30604 b8d532cb6420
parent 29678 dd2f3932c21e
child 35061 be6025ebffea
permissions -rw-r--r--
8067013: Rename the com.oracle.java.testlibary package Reviewed-by: dholmes, gtriantafill, sla Contributed-by: alexander.kulyakhtin@oracle.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",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    52
                                               "-XX:+PrintGC",
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
                                               "-XX:G1LogLevel=finest",
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    55
                                               "-XX:+G1TraceEagerReclaimHumongousObjects",
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    56
                                               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
    57
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    58
    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
    59
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    60
    // 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
    61
    // And GCTest doesn't have humongous objects, so values should be zero.
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    62
    output.shouldContain("[Humongous Reclaim");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    63
    output.shouldContain("[Humongous Total: 0]");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    64
    output.shouldContain("[Humongous Candidate: 0]");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    65
    output.shouldContain("[Humongous Reclaimed: 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
    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
    68
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    69
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    70
  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
    71
    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
    72
                                               "-Xms128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    73
                                               "-Xmx128M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    74
                                               "-Xmn16M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    75
                                               "-XX:G1HeapRegionSize=1M",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    76
                                               "-XX:+PrintGC",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    77
                                               "-XX:+UnlockExperimentalVMOptions",
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    78
                                               "-XX:G1LogLevel=finest",
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    79
                                               "-XX:+G1TraceEagerReclaimHumongousObjects",
27151
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    80
                                               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
    81
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    82
    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
    83
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    84
    // As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below 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
    85
    output.shouldContain("[Humongous Reclaim");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    86
    output.shouldContain("[Humongous Total");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    87
    output.shouldContain("[Humongous Candidate");
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("[Humongous Reclaimed");
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    89
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    90
    // 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
    91
    // 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
    92
    output.shouldContain("Live humongous");
28379
e6784fc8fff2 8048179: Early reclaim of large objects that are referenced by a few objects
tschatzl
parents: 27151
diff changeset
    93
    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
    94
    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
    95
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    96
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
    97
  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
    98
    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
    99
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   100
    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
   101
      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
   102
      // 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
   103
      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
   104
        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
   105
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   106
      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
   107
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   108
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   109
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   110
  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
   111
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   112
    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
   113
    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
   114
    // 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
   115
    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
   116
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   117
    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
   118
      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
   119
        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
   120
      }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   121
      garbageList.clear();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   122
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   123
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   124
    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
   125
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   126
      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
   127
      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
   128
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   129
      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
   130
      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
   131
        // 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
   132
        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
   133
        genGarbage();
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   134
        // 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
   135
        // 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
   136
        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
   137
      }
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
      // 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
   140
      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
   141
      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
   142
    }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   143
  }
46c8a68473f0 8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
tschatzl
parents:
diff changeset
   144
}