Skip to content
Permalink
Browse files

8240634: event/runtime/TestMetaspaceAllocationFailure.java times out

Limit number of iterations

Reviewed-by: egahlin, stuefe
  • Loading branch information
Mikhailo Seledtsov
Mikhailo Seledtsov committed Mar 26, 2020
1 parent 54e2c6f commit 098b48b7db6ce09b356111d3cff802345e2cbf31
Showing with 12 additions and 4 deletions.
  1. +12 −4 test/jdk/jdk/jfr/event/runtime/TestMetaspaceAllocationFailure.java
@@ -29,9 +29,11 @@
* @modules java.base/jdk.internal.misc java.compiler
* @run main/othervm -Xmx1G -XX:MaxMetaspaceSize=200M
* -XX:StartFlightRecording -Xshare:off
* -Xlog:gc+metaspace*=debug
* jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
* @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=200M
* @run main/othervm -Xmx1G -XX:CompressedClassSpaceSize=10M
* -XX:StartFlightRecording -Xshare:off
* -Xlog:gc+metaspace*=debug
* jdk.jfr.event.runtime.TestMetaspaceAllocationFailure
*/
package jdk.jfr.event.runtime;
@@ -40,21 +42,27 @@
import jdk.jfr.consumer.RecordingStream;
import jdk.test.lib.classloader.GeneratingCompilingClassLoader;
import jdk.test.lib.Asserts;

import jtreg.SkippedException;

public class TestMetaspaceAllocationFailure {
private static final int MAX_ITERATIONS = 100;

public static void main(String... args) throws Exception {
AtomicBoolean eventArrived = new AtomicBoolean(false);

try (RecordingStream r = new RecordingStream()) {
r.onEvent("jdk.MetaspaceAllocationFailure", e -> eventArrived.set(true));
r.startAsync();

try {
int iteration = 0;
while (!eventArrived.get()) {
GeneratingCompilingClassLoader cl = new GeneratingCompilingClassLoader();
cl.getGeneratedClasses(50, 20);
Thread.sleep(100);
System.out.println("Iteration");
System.out.println("Iteration:" + iteration++);
if (iteration > MAX_ITERATIONS) {
throw new SkippedException("Exceeded MAX_ITERATIONS of " + MAX_ITERATIONS);
}
}
System.gc();
System.out.println("main(): Event arrived");

0 comments on commit 098b48b

Please sign in to comment.