Fix gc/class_unloading/.. tests
--- 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) {