/* * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
package gc.g1;
/* * @test TestEvacuationFailure * @summary Ensure the output for a minor GC with G1 that has evacuation failure contains the correct strings. * @requires vm.gc.G1 * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * gc.g1.TestEvacuationFailure
*/
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println(output.getStdout());
output.shouldContain("(Evacuation Failure)");
output.shouldHaveExitValue(0);
}
staticclass GCTestWithEvacuationFailure { privatestaticbyte[] garbage; privatestaticbyte[] largeObject; privatestatic Object[] holder = new Object[200]; // Must be larger than G1EvacuationFailureALotCount
publicstaticvoid main(String [] args) {
largeObject = newbyte[16 * 1024 * 1024];
System.out.println("Creating garbage"); // Create 16 MB of garbage. This should result in at least one GC, // (Heap size is 32M, we use 17MB for the large object above) // which is larger than G1EvacuationFailureALotInterval. for (int i = 0; i < 16 * 1024; i++) {
holder[i % holder.length] = newbyte[1024];
}
System.out.println("Done");
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.