Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

import sun.hotspot.WhiteBox;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class MetaspaceTestContext {

Expand Down Expand Up @@ -140,6 +138,9 @@ public void checkStatistics() {
long usageMeasured = usedWords();
long committedMeasured = committedWords();

System.out.println("context used words " + usageMeasured + ", committed words " + committedMeasured
+ ".");

if (usageMeasured > committedMeasured) {
throw new RuntimeException("Weirdness.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public void runTest() throws Exception {
// Stop all threads.
stopAllThreads();

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

context.updateTotals();
System.out.println(" ## Finished: " + context);

Expand Down