Skip to content

Commit a3406a1

Browse files
committedNov 19, 2021
8277092: TestMetaspaceAllocationMT2.java#ndebug-default fails with "RuntimeException: Committed seems high: NNNN expected at most MMMM"
Reviewed-by: coleenp
1 parent e47cc81 commit a3406a1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestContext.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

22
import sun.hotspot.WhiteBox;
33

4-
import java.util.ArrayList;
54
import java.util.HashSet;
6-
import java.util.List;
75

86
public class MetaspaceTestContext {
97

@@ -140,6 +138,9 @@ public void checkStatistics() {
140138
long usageMeasured = usedWords();
141139
long committedMeasured = committedWords();
142140

141+
System.out.println("context used words " + usageMeasured + ", committed words " + committedMeasured
142+
+ ".");
143+
143144
if (usageMeasured > committedMeasured) {
144145
throw new RuntimeException("Weirdness.");
145146
}

‎test/hotspot/jtreg/runtime/Metaspace/elastic/MetaspaceTestManyArenasManyThreads.java

+13
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ public void runTest() throws Exception {
8383
// Stop all threads.
8484
stopAllThreads();
8585

86+
// At this point a large number of Arenas will have died (see above), but we probably still have
87+
// some live arenas left. The chunk freelist will be full of free chunks. Maybe a bit fragmented,
88+
// with a healthy mixture of larger and smaller chunks, since we still have live arenas.
89+
// These chunks are all committed still, since we did nothing to reclaim the storage. We now purge
90+
// the context manually to uncommit those chunks, in order to get a realistic number for
91+
// committed words (see checkStatistics()).
92+
// Note: In real metaspace, this happens as part of the same GC which removes class loaders and
93+
// frees their metaspace arenas. All within CLDG::purge(). But since this test isolates the metaspace
94+
// context and does test it separately, GC and CLDG are not involved here. We need to purge manually.
95+
//
96+
// Purging uncommits all free chunks >= 64K/16K (MetaspaceReclaimPolicy=standard/aggressive).
97+
context.purge();
98+
8699
context.updateTotals();
87100
System.out.println(" ## Finished: " + context);
88101

0 commit comments

Comments
 (0)