Path: blob/master/test/hotspot/jtreg/gc/g1/TestEdenSurvivorLessThanMax.java
40942 views
/*1* Copyright (c) 2018, 2021, 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 TestEdenSurvivorLessThanMax27* @bug 815272428* @summary Check that G1 eden plus survivor max capacity after GC does not exceed maximum number of regions.29* @requires vm.gc.G130* @library /test/lib31* @build sun.hotspot.WhiteBox32* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox33* @run main/othervm -Xbootclasspath/a:. -Xlog:gc+heap=debug -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx64M -Xms64M -Xmn50M -XX:SurvivorRatio=1 gc.g1.TestEdenSurvivorLessThanMax34*/3536import sun.hotspot.WhiteBox;3738// The test fills the heap in a way that previous to 8152724 the maximum number of survivor regions39// for that young gc was higher than there was free space left which is impossible.40public class TestEdenSurvivorLessThanMax {41private static final long BYTES_TO_FILL = 50 * 1024 * 1024;4243private static final WhiteBox WB = WhiteBox.getWhiteBox();4445public static void main(String[] args) throws Exception {46Object o = new int[100];4748long objSize = WB.getObjectSize(o);4950// Fill eden to approximately ~90%.51int numObjs = (int)((BYTES_TO_FILL / objSize) * 9 / 10);52for (int i = 0; i < numObjs; i++) {53o = new int[100];54}5556WB.youngGC();5758System.out.println(o.toString());59}60}61626364