annotate test/gc/g1/TestEagerReclaimHumongousRegions.java @ 20526:584df6794686

Added tag hs25.40-b14 for changeset e193bbae24ef
author amurillo
date Fri, 10 Oct 2014 03:07:09 -0700
parents a3953c777565
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20296
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
1 /*
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
4 *
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
7 * published by the Free Software Foundation.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
8 *
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
13 * accompanied this code).
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
14 *
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
18 *
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
21 * questions.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
22 */
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
23
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
24 /*
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
25 * @test TestEagerReclaimHumongousRegions
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
26 * @bug 8027959
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
27 * @summary Test to make sure that eager reclaim of humongous objects work. We simply try to fill
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
28 * up the heap with humongous objects that should be eagerly reclaimable to avoid Full GC.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
29 * @key gc
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
30 * @library /testlibrary
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
31 */
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
32
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
33 import java.util.regex.Pattern;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
34 import java.util.regex.Matcher;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
35 import java.util.LinkedList;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
36
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
37 import com.oracle.java.testlibrary.OutputAnalyzer;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
38 import com.oracle.java.testlibrary.ProcessTools;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
39 import com.oracle.java.testlibrary.Asserts;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
40
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
41 class ReclaimRegionFast {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
42 public static final int M = 1024*1024;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
43
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
44 public static LinkedList<Object> garbageList = new LinkedList<Object>();
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
45
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
46 public static void genGarbage() {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
47 for (int i = 0; i < 32*1024; i++) {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
48 garbageList.add(new int[100]);
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
49 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
50 garbageList.clear();
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
51 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
52
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
53 // A large object referenced by a static.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
54 static int[] filler = new int[10 * M];
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
55
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
56 public static void main(String[] args) {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
57
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
58 int[] large = new int[M];
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
59
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
60 Object ref_from_stack = large;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
61
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
62 for (int i = 0; i < 100; i++) {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
63 // A large object that will be reclaimed eagerly.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
64 large = new int[6*M];
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
65 genGarbage();
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
66 // Make sure that the compiler cannot completely remove
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
67 // the allocation of the large object until here.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
68 System.out.println(large);
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
69 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
70
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
71 // Keep the reference to the first object alive.
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
72 System.out.println(ref_from_stack);
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
73 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
74 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
75
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
76 public class TestEagerReclaimHumongousRegions {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
77 public static void main(String[] args) throws Exception {
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
78 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
79 "-XX:+UseG1GC",
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
80 "-Xms128M",
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
81 "-Xmx128M",
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
82 "-Xmn16M",
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
83 "-XX:+PrintGC",
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
84 ReclaimRegionFast.class.getName());
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
85
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
86 Pattern p = Pattern.compile("Full GC");
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
87
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
88 OutputAnalyzer output = new OutputAnalyzer(pb.start());
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
89
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
90 int found = 0;
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
91 Matcher m = p.matcher(output.getStdout());
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
92 while (m.find()) { found++; }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
93 System.out.println("Issued " + found + " Full GCs");
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
94 Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
95
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
96 output.shouldHaveExitValue(0);
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
97 }
a3953c777565 8027959: Early reclamation of large objects in G1
tschatzl
parents:
diff changeset
98 }