Fix gc/class_unloading/.. tests stuefe-new-metaspace-branch
authorstuefe
Thu, 19 Sep 2019 16:28:40 +0200
branchstuefe-new-metaspace-branch
changeset 58228 6e61beb13680
parent 58227 0e7d9a23261e
child 58333 78b2e8f46dd4
Fix gc/class_unloading/.. tests
src/hotspot/share/memory/metaspace/spaceManager.cpp
test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java
test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java
--- a/src/hotspot/share/memory/metaspace/spaceManager.cpp	Thu Sep 19 15:21:27 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/spaceManager.cpp	Thu Sep 19 16:28:40 2019 +0200
@@ -93,8 +93,9 @@
 
   assert_lock_strong(lock());
 
-  guarantee(requested_word_size < chklvl::MAX_CHUNK_WORD_SIZE,
-            "Requested size too large (" SIZE_FORMAT ").", requested_word_size);
+  guarantee(requested_word_size <= chklvl::MAX_CHUNK_WORD_SIZE,
+            "Requested size too large (" SIZE_FORMAT ") - max allowed size per allocation is " SIZE_FORMAT ".",
+            requested_word_size, chklvl::MAX_CHUNK_WORD_SIZE);
 
   // If we have a current chunk, it should have been retired (almost empty) beforehand.
   // See: retire_current_chunk().
--- a/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Thu Sep 19 15:21:27 2019 +0200
+++ b/test/hotspot/jtreg/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java	Thu Sep 19 16:28:40 2019 +0200
@@ -106,7 +106,14 @@
       // Allocate past the MetaspaceSize limit.
       long metaspaceSize = Long.parseLong(args[0]);
       long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
-      long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);
+
+      // There is a max. value to how much metaspace can be allocated in one allocation.
+      final long max = 1024 * 1024 * 4;
+      while (allocationBeyondMetaspaceSize > 0) {
+        long s = max < allocationBeyondMetaspaceSize ? max : allocationBeyondMetaspaceSize;
+        wb.allocateMetaspace(null, s);
+        allocationBeyondMetaspaceSize -= s;
+      }
 
       // Wait for at least one GC to occur. The caller will parse the log files produced.
       GarbageCollectorMXBean cmsGCBean = getCMSGCBean();
@@ -114,7 +121,6 @@
         Thread.sleep(100);
       }
 
-      wb.freeMetaspace(null, metaspace, metaspace);
     }
 
     private static GarbageCollectorMXBean getCMSGCBean() {
--- a/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java	Thu Sep 19 15:21:27 2019 +0200
+++ b/test/hotspot/jtreg/gc/class_unloading/TestG1ClassUnloadingHWM.java	Thu Sep 19 16:28:40 2019 +0200
@@ -104,12 +104,18 @@
       // Allocate past the MetaspaceSize limit
       long metaspaceSize = Long.parseLong(args[0]);
       long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
-      long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);
+
+      // There is a max. value to how much metaspace can be allocated in one allocation.
+      final long max = 1024 * 1024 * 4;
+      while (allocationBeyondMetaspaceSize > 0) {
+        long s = max < allocationBeyondMetaspaceSize ? max : allocationBeyondMetaspaceSize;
+        wb.allocateMetaspace(null, s);
+        allocationBeyondMetaspaceSize -= s;
+      }
 
       long youngGenSize = Long.parseLong(args[1]);
       triggerYoungGCs(youngGenSize);
 
-      wb.freeMetaspace(null, metaspace, metaspace);
     }
 
     public static void triggerYoungGCs(long youngGenSize) {