< prev index next >
test/gc/metaspace/TestMetaspaceCMSCancel.java
Print this page
rev 11252 : 8026752: Cancel MetaspaceGC request for a CMS concurrent collection after GC
Reviewed-by:
rev 11253 : [mq]: whitebox
*** 18,68 ****
*
* 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.
*/
! import jdk.test.lib.ProcessTools;
! import jdk.test.lib.OutputAnalyzer;
! import java.util.ArrayList;
/* @test TestMetaspaceCMSCancel
* @bug 8026752
* @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC
! * @library /testlibrary
* @modules java.base/jdk.internal.misc
*/
public class TestMetaspaceCMSCancel {
public static void main(String[] args) throws Exception {
// Set a small MetaspaceSize so that a CMS concurrent collection will be
// scheduled. Set CMSWaitDuration to 5s so that the concurrent collection
// start may be delayed. It does not guarantee 5s before the start of the
// concurrent collection but does increase the probability that it will
// be started later. System.gc() is used to invoke a full collection. Set
// ExplicitGCInvokesConcurrent to off so it is a STW collection.
! ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseConcMarkSweepGC",
"-XX:MetaspaceSize=2m",
"-XX:CMSWaitDuration=5000",
"-XX:-ExplicitGCInvokesConcurrent",
"-Xlog:gc*=debug",
MetaspaceGCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
-
output.shouldNotContain("Concurrent Reset");
output.shouldHaveExitValue(0);
}
static class MetaspaceGCTest {
public static void main(String [] args) {
System.gc();
! while (true) {
! try {
! Thread.sleep(20000);
! return;
! } catch (InterruptedException e) {
! continue;
! }
! }
}
}
}
--- 18,70 ----
*
* 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.
*/
! import jdk.test.lib.process.ProcessTools;
! import jdk.test.lib.process.OutputAnalyzer;
! import jdk.test.lib.Asserts;
! import sun.hotspot.WhiteBox;
/* @test TestMetaspaceCMSCancel
* @bug 8026752
* @summary Tests cancel of CMS concurrent cycle for Metaspace after a full GC
! * @library /testlibrary /test/lib /test/lib/share/classes
* @modules java.base/jdk.internal.misc
+ * @build TestMetaspaceCMSCancel
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm TestMetaspaceCMSCancel
*/
+
+
public class TestMetaspaceCMSCancel {
public static void main(String[] args) throws Exception {
// Set a small MetaspaceSize so that a CMS concurrent collection will be
// scheduled. Set CMSWaitDuration to 5s so that the concurrent collection
// start may be delayed. It does not guarantee 5s before the start of the
// concurrent collection but does increase the probability that it will
// be started later. System.gc() is used to invoke a full collection. Set
// ExplicitGCInvokesConcurrent to off so it is a STW collection.
! ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:.",
! "-XX:+UnlockDiagnosticVMOptions",
! "-XX:+WhiteBoxAPI",
! "-XX:+UseConcMarkSweepGC",
"-XX:MetaspaceSize=2m",
"-XX:CMSWaitDuration=5000",
"-XX:-ExplicitGCInvokesConcurrent",
"-Xlog:gc*=debug",
MetaspaceGCTest.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("Concurrent Reset");
output.shouldHaveExitValue(0);
}
static class MetaspaceGCTest {
public static void main(String [] args) {
+ WhiteBox wb = WhiteBox.getWhiteBox();
System.gc();
! Asserts.assertFalse(wb.metaspaceShouldConcurrentCollect());
}
}
}
< prev index next >