< prev index next >
test/runtime/Metaspace/FragmentMetaspace.java
Print this page
@@ -23,11 +23,11 @@
/**
* @test
* @library /runtime/testlibrary
* @build GeneratedClassLoader
- * @run main/othervm/timeout=200 FragmentMetaspace
+ * @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
*/
import java.io.IOException;
/**
@@ -36,24 +36,27 @@
* iteration. By increasing the size of the class meta data needed for every iteration
* we stress the subsystem for allocating native memory for meta data.
*/
public class FragmentMetaspace {
+ public static Class<?> c;
+
public static void main(String... args) {
- runGrowing(Long.valueOf(System.getProperty("time", "80000")));
+ runGrowing(Long.valueOf(System.getProperty("time", "80000")),
+ Integer.valueOf(System.getProperty("iterations","200")));
// try to clean up and unload classes to decrease
// class verification time in debug vm
System.gc();
}
- private static void runGrowing(long time) {
+ private static void runGrowing(long time,int iterations) {
long startTime = System.currentTimeMillis();
- for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) {
+ for (int i = 0; System.currentTimeMillis() < startTime + time && i<iterations; ++i) {
try {
GeneratedClassLoader gcl = new GeneratedClassLoader();
- Class<?> c = gcl.getGeneratedClasses(i, 100)[0];
+ c = gcl.getGeneratedClasses(i, 100)[0];
c.newInstance();
c = null;
gcl = null;
} catch (IOException|InstantiationException|IllegalAccessException ex) {
< prev index next >