Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8277092: TestMetaspaceAllocationMT2.java#ndebug-default fails with "R…
…untimeException: Committed seems high: NNNN expected at most MMMM"

Backport-of: a3406a1d8ab4228b06b4f2978f87275093c39468
  • Loading branch information
GoeLin committed Sep 19, 2022
1 parent a5dceb7 commit 2e5287b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
@@ -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
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

1 comment on commit 2e5287b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.