RFR: 8342283: CDS cannot handle a large number of classes

Ioi Lam iklam at openjdk.org
Thu Oct 31 03:57:03 UTC 2024


When lots of classes are loaded during `java -Xshare:dump`, the internal arrays used by some of the HashMaps and ArrayLists become too large to be archived by CDS (> 256KB).

At the very end of Java bytecode execution during `java -Xshare:dump`, we used to call `clear()` on these tables to free their elements (*) -- these tables are repopulated at run time when classes are loaded incrementally. However, the `clear()` call doesn't resize the internal arrays.

The fix is to re-ininitialize these tables to new, empty tables that have small internal arrays.

===
(*) the call to `resetArchivedStates()` is made from [HeapShared::reset_archived_object_states()](https://github.com/openjdk/jdk/blob/688e92e7f5febddd2935cb7f500dd3f10fbd9401/src/hotspot/share/cds/metaspaceShared.cpp#L799)

-------------

Commit messages:
 - 8342283: CDS cannot handle a large number of classes

Changes: https://git.openjdk.org/jdk/pull/21797/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21797&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8342283
  Stats: 14 lines in 1 file changed: 5 ins; 0 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/21797.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/21797/head:pull/21797

PR: https://git.openjdk.org/jdk/pull/21797


More information about the core-libs-dev mailing list