File tree 2 files changed +16
-2
lines changed
test/hotspot/jtreg/runtime/Metaspace/elastic
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
2
2
import sun .hotspot .WhiteBox ;
3
3
4
- import java .util .ArrayList ;
5
4
import java .util .HashSet ;
6
- import java .util .List ;
7
5
8
6
public class MetaspaceTestContext {
9
7
@@ -140,6 +138,9 @@ public void checkStatistics() {
140
138
long usageMeasured = usedWords ();
141
139
long committedMeasured = committedWords ();
142
140
141
+ System .out .println ("context used words " + usageMeasured + ", committed words " + committedMeasured
142
+ + "." );
143
+
143
144
if (usageMeasured > committedMeasured ) {
144
145
throw new RuntimeException ("Weirdness." );
145
146
}
Original file line number Diff line number Diff line change @@ -83,6 +83,19 @@ public void runTest() throws Exception {
83
83
// Stop all threads.
84
84
stopAllThreads ();
85
85
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
+
86
99
context .updateTotals ();
87
100
System .out .println (" ## Finished: " + context );
88
101
You can’t perform that action at this time.
0 commit comments