8155570: serviceability/tmtools/jstat/GcTest02.java fails with parallel GC
authorlmesnik
Wed, 19 Oct 2016 10:10:51 +0300
changeset 42021 390db590f103
parent 42019 3755a8d3b514
child 42022 3d15294ea920
8155570: serviceability/tmtools/jstat/GcTest02.java fails with parallel GC Reviewed-by: jwilhelm
hotspot/test/serviceability/tmtools/jstat/GcTest02.java
hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java
--- a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java	Wed Oct 19 12:10:43 2016 +0200
+++ b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java	Wed Oct 19 10:10:51 2016 +0300
@@ -31,7 +31,6 @@
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @library ../share
- * @ignore 8155570
  * @run main/othervm -XX:+UsePerfData -Xmx128M -XX:MaxMetaspaceSize=128M GcTest02
  */
 
--- a/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java	Wed Oct 19 12:10:43 2016 +0200
+++ b/hotspot/test/serviceability/tmtools/jstat/utils/GcProvokerImpl.java	Wed Oct 19 10:10:51 2016 +0300
@@ -50,7 +50,7 @@
                 used += memoryChunk;
             } catch (OutOfMemoryError e) {
                 list = null;
-                throw new RuntimeException("Unexpected OOME while eating " + targetUsage + " of heap memory.");
+                throw new RuntimeException("Unexpected OOME '" + e.getMessage() + "' while eating " + targetUsage + " of heap memory.");
             }
         }
         return list;
@@ -73,8 +73,10 @@
 
     @Override
     public void eatMetaspaceAndHeap(float targetMemoryUsagePercent) {
+        // Metaspace should be filled before Java Heap to prevent unexpected OOME
+        // in the Java Heap while filling Metaspace
+        eatenMetaspace = eatMetaspace(targetMemoryUsagePercent);
         eatenMemory = eatHeapMemory(targetMemoryUsagePercent);
-        eatenMetaspace = eatMetaspace(targetMemoryUsagePercent);
     }
 
     private static List<Object> eatMetaspace(float targetUsage) {
@@ -97,7 +99,7 @@
                 list.add(gp.create(0));
             } catch (OutOfMemoryError oome) {
                 list = null;
-                throw new RuntimeException("Unexpected OOME while eating " + targetUsage + " of Metaspace.");
+                throw new RuntimeException("Unexpected OOME '" + oome.getMessage() + "' while eating " + targetUsage + " of Metaspace.");
             }
             MemoryUsage memoryUsage = metaspacePool.getUsage();
             currentUsage = (((float) memoryUsage.getUsed()) / memoryUsage.getMax());