Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java
32284 views
/*1* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test TestHumongousAllocInitialMark25* @bug 716884826* @summary G1: humongous object allocations should initiate marking cycles when necessary27* @library /testlibrary28*/2930import com.oracle.java.testlibrary.*;3132public class TestHumongousAllocInitialMark {33private static final int heapSize = 200; // MB34private static final int heapRegionSize = 1; // MB35private static final int initiatingHeapOccupancyPercent = 50; // %3637public static void main(String[] args) throws Exception {38ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(39"-XX:+UseG1GC",40"-Xms" + heapSize + "m",41"-Xmx" + heapSize + "m",42"-XX:G1HeapRegionSize=" + heapRegionSize + "m",43"-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,44"-XX:+PrintGC",45HumongousObjectAllocator.class.getName());4647OutputAnalyzer output = new OutputAnalyzer(pb.start());48output.shouldContain("GC pause (G1 Humongous Allocation) (young) (initial-mark)");49output.shouldNotContain("Full GC");50output.shouldHaveExitValue(0);51}5253static class HumongousObjectAllocator {54private static byte[] dummy;5556public static void main(String [] args) throws Exception {57// Make object size 75% of region size58final int humongousObjectSize =59(int)(heapRegionSize * 1024 * 1024 * 0.75);6061// Number of objects to allocate to go above IHOP62final int humongousObjectAllocations =63(int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1;6465// Allocate66for (int i = 1; i <= humongousObjectAllocations; i++) {67System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations +68" of size " + humongousObjectSize + " bytes");69dummy = new byte[humongousObjectSize];70}71}72}73}74757677