8214217: [TESTBUG] runtime/appcds/LotsOfClasses.java failed with fragmented heap
Summary: Improve the fragmentation error message. Set java heap size in LotsOfClasses.java.
Reviewed-by: iklam, ccheung
--- a/src/hotspot/share/memory/filemap.cpp Tue Nov 27 13:39:57 2018 -0500
+++ b/src/hotspot/share/memory/filemap.cpp Tue Nov 27 17:53:17 2018 -0500
@@ -683,7 +683,10 @@
int arr_len = heap_mem == NULL ? 0 : heap_mem->length();
if(arr_len > max_num_regions) {
fail_stop("Unable to write archive heap memory regions: "
- "number of memory regions exceeds maximum due to fragmentation");
+ "number of memory regions exceeds maximum due to fragmentation."
+ "Please increase java heap size "
+ "(current MaxHeapSize is " SIZE_FORMAT ", InitialHeapSize is " SIZE_FORMAT ").",
+ MaxHeapSize, InitialHeapSize);
}
size_t total_size = 0;
--- a/test/hotspot/jtreg/runtime/appcds/LotsOfClasses.java Tue Nov 27 13:39:57 2018 -0500
+++ b/test/hotspot/jtreg/runtime/appcds/LotsOfClasses.java Tue Nov 27 17:53:17 2018 -0500
@@ -57,9 +57,16 @@
opts.addSuffix("--add-modules");
opts.addSuffix("ALL-SYSTEM");
opts.addSuffix("-Xlog:hashtables");
+ opts.addSuffix("-Xms500m");
+ opts.addSuffix("-Xmx500m");
OutputAnalyzer out = CDSTestUtils.createArchive(opts);
- CDSTestUtils.checkDump(out);
+ try {
+ CDSTestUtils.checkDump(out);
+ } catch (java.lang.RuntimeException re) {
+ out.shouldContain(
+ "number of memory regions exceeds maximum due to fragmentation");
+ }
}
static void findAllClasses(ArrayList<String> list) throws Throwable {