Mercurial > hg > truffle
comparison test/gc/g1/TestHumongousAllocInitialMark.java @ 12898:6f1919cfd18c
8023158: hotspot/test/gc/7168848/HumongousAlloc.java fails 14 full gcs, expect 0 full gcs
Reviewed-by: brutisso, tschatzl
author | pliden |
---|---|
date | Tue, 15 Oct 2013 11:38:47 +0200 |
parents | test/gc/7168848/HumongousAlloc.java@9a344d88dc22 |
children | de6a9e811145 |
comparison
equal
deleted
inserted
replaced
12895:d6818f623792 | 12898:6f1919cfd18c |
---|---|
1 /* | |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
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 /* | |
25 * @test TestHumongousAllocInitialMark | |
26 * @bug 7168848 | |
27 * @summary G1: humongous object allocations should initiate marking cycles when necessary | |
28 * @library /testlibrary | |
29 */ | |
30 | |
31 import com.oracle.java.testlibrary.*; | |
32 | |
33 public class TestHumongousAllocInitialMark { | |
34 private static final int heapSize = 200; // MB | |
35 private static final int heapRegionSize = 1; // MB | |
36 private static final int initiatingHeapOccupancyPercent = 50; // % | |
37 | |
38 public static void main(String[] args) throws Exception { | |
39 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( | |
40 "-XX:+UseG1GC", | |
41 "-Xms" + heapSize + "m", | |
42 "-Xmx" + heapSize + "m", | |
43 "-XX:G1HeapRegionSize=" + heapRegionSize + "m", | |
44 "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent, | |
45 "-XX:+PrintGC", | |
46 HumongousObjectAllocator.class.getName()); | |
47 | |
48 OutputAnalyzer output = new OutputAnalyzer(pb.start()); | |
49 output.shouldContain("GC pause (G1 Humongous Allocation) (young) (initial-mark)"); | |
50 output.shouldNotContain("Full GC"); | |
51 output.shouldHaveExitValue(0); | |
52 } | |
53 | |
54 static class HumongousObjectAllocator { | |
55 private static byte[] dummy; | |
56 | |
57 public static void main(String [] args) throws Exception { | |
58 // Make object size 75% of region size | |
59 final int humongousObjectSize = | |
60 (int)(heapRegionSize * 1024 * 1024 * 0.75); | |
61 | |
62 // Number of objects to allocate to go above IHOP | |
63 final int humongousObjectAllocations = | |
64 (int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1; | |
65 | |
66 // Allocate | |
67 for (int i = 1; i <= humongousObjectAllocations; i++) { | |
68 System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations + | |
69 " of size " + humongousObjectSize + " bytes"); | |
70 dummy = new byte[humongousObjectSize]; | |
71 } | |
72 } | |
73 } | |
74 } | |
75 |