Path: blob/master/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java
40942 views
/*1* Copyright (c) 2012, 2019, 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*/2223package gc.g1;2425import static gc.testlibrary.Allocation.blackHole;2627/*28* @test TestHumongousAllocNearlyFullRegion29* @bug 814358730* @summary G1: humongous object allocations should work even when there is31* not enough space in the heapRegion to fit a filler object.32* @requires vm.gc.G133* @modules java.base/jdk.internal.misc34* @library /test/lib35* @library /36* @run driver gc.g1.TestHumongousAllocNearlyFullRegion37*/3839import jdk.test.lib.process.OutputAnalyzer;40import jdk.test.lib.process.ProcessTools;4142public class TestHumongousAllocNearlyFullRegion {43// Heap sizes < 224 MB are increased to 224 MB if vm_page_size == 64K to44// fulfill alignment constraints.45private static final int heapSize = 224; // MB46private static final int heapRegionSize = 1; // MB4748public static void main(String[] args) throws Exception {49ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(50"-XX:+UseG1GC",51"-Xms" + heapSize + "m",52"-Xmx" + heapSize + "m",53"-XX:G1HeapRegionSize=" + heapRegionSize + "m",54"-Xlog:gc",55HumongousObjectAllocator.class.getName());5657OutputAnalyzer output = new OutputAnalyzer(pb.start());58output.shouldContain("Pause Young (Concurrent Start) (G1 Humongous Allocation)");59output.shouldHaveExitValue(0);60}6162static class HumongousObjectAllocator {63public static void main(String [] args) {64for (int i = 0; i < heapSize; i++) {65// 131069 is the number of longs it takes to fill a heapRegion except66// for 8 bytes on 64 bit.67blackHole(new long[131069]);68}69}70}71}72737475