Path: blob/master/test/hotspot/jtreg/gc/g1/TestHumongousAllocConcurrentStart.java
40942 views
/*1* Copyright (c) 2012, 2020, 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;2425/*26* @test TestHumongousAllocConcurrentStart27* @bug 716884828* @summary G1: humongous object allocations should initiate marking cycles when necessary29* @requires vm.gc.G130* @library /test/lib31* @modules java.base/jdk.internal.misc32* java.management33* @run driver gc.g1.TestHumongousAllocConcurrentStart34*/3536import jdk.test.lib.process.OutputAnalyzer;37import jdk.test.lib.process.ProcessTools;3839public class TestHumongousAllocConcurrentStart {40// Heap sizes < 224 MB are increased to 224 MB if vm_page_size == 64K to41// fulfill alignment constraints.42private static final int heapSize = 224; // MB43private static final int heapRegionSize = 1; // MB44private static final int initiatingHeapOccupancyPercent = 50; // %4546public static void main(String[] args) throws Exception {47ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(48"-XX:+UseG1GC",49"-Xms" + heapSize + "m",50"-Xmx" + heapSize + "m",51"-XX:G1HeapRegionSize=" + heapRegionSize + "m",52"-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent,53"-Xlog:gc",54HumongousObjectAllocator.class.getName());5556OutputAnalyzer output = new OutputAnalyzer(pb.start());57output.shouldContain("Pause Young (Concurrent Start) (G1 Humongous Allocation)");58output.shouldNotContain("Full GC");59output.shouldHaveExitValue(0);60}6162static class HumongousObjectAllocator {63private static byte[] dummy;6465public static void main(String [] args) throws Exception {66// Make object size 75% of region size67final int humongousObjectSize =68(int)(heapRegionSize * 1024 * 1024 * 0.75);6970// Number of objects to allocate to go above IHOP71final int humongousObjectAllocations =72(int)((heapSize * initiatingHeapOccupancyPercent / 100.0) / heapRegionSize) + 1;7374// Allocate75for (int i = 1; i <= humongousObjectAllocations; i++) {76System.out.println("Allocating humongous object " + i + "/" + humongousObjectAllocations +77" of size " + humongousObjectSize + " bytes");78dummy = new byte[humongousObjectSize];79}80}81}82}83848586