< prev index next >

test/serviceability/tmtools/jstat/GcTest02.java

Print this page

        

@@ -26,14 +26,15 @@
  * @test
  * @summary Test checks output displayed with jstat -gc.
  *          Test scenario:
  *          tests forces debuggee application eat ~70% of heap and runs jstat.
  *          jstat should show that ~70% of heap is utilized (OC/OU ~= 70%).
+ * @requires vm.opt.ExplicitGCInvokesConcurrent != true
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @library ../share
- * @run main/othervm -XX:+UsePerfData -Xmx128M -XX:MaxMetaspaceSize=128M GcTest02
+ * @run main/othervm -XX:+UsePerfData -XX:InitialHeapSize=128M -XX:MaxHeapSize=128M -XX:MaxMetaspaceSize=128M GcTest02
  */
 
 public class GcTest02 {
 
     private final static float targetMemoryUsagePercent = 0.7f;

@@ -45,14 +46,16 @@
 
         // Run once and get the  results asserting that they are reasonable
         JstatGcResults measurement1 = jstatGcTool.measure();
         measurement1.assertConsistency();
 
-        GcProvoker gcProvoker = GcProvoker.createGcProvoker();
+        GcProvoker gcProvoker = new GcProvoker();
 
         // Eat metaspace and heap then run the tool again and get the results  asserting that they are reasonable
-        gcProvoker.eatMetaspaceAndHeap(targetMemoryUsagePercent);
+        gcProvoker.allocateAvailableMetaspaceAndHeap(targetMemoryUsagePercent);
+        // Collect garbage. Also updates VM statistics
+        System.gc();
         JstatGcResults measurement2 = jstatGcTool.measure();
         measurement2.assertConsistency();
 
         // Assert that space has been utilized acordingly
         JstatResults.assertSpaceUtilization(measurement2, targetMemoryUsagePercent);
< prev index next >