JDK-8217432 : MetaspaceGC::_capacity_until_GC exceeds MaxMetaspaceSize
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8,9,10,11,12,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-01-21
  • Updated: 2020-09-24
  • Resolved: 2019-02-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 12 JDK 13 Other
11.0.3Fixed 12.0.2Fixed 13 b07Fixed openjdk8u212Fixed
Related Reports
Relates :  
Description
https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/2019-January/024465.html


My customer uses OpenJDK 8u131 with following commandline arguments:

   -XX:+CMSClassUnloadingEnabled -XX:CMSInitiatingOccupancyFraction=80
   -XX:CompressedClassSpaceSize=128m -Xms4500m -Xmx4500m
   -XX:MaxMetaspaceSize=256m -Xmn=768m -XX:MaxTenuringThreshold=15
   -XX:OnOutOfMemoryError="/bin/kill -ABRT %p"
   -XX:+UseCMSInitiatingOccupancyOnly -XX:+UseConcMarkSweepGC

Their system has encountered OutOfMemoryError which is caused by Metaspace.

I checked core image which was collected by OnOutOfMemoryError, and I saw
strange values in it as below:

-------------------
(gdb) p Metaspace::_space_list->_reserved_words
$67 = 31195136
(gdb) p Metaspace::_class_space_list->_reserved_words
$68 = 16777216
(gdb) p MetaspaceGC::_capacity_until_GC
$75 = 448045056
-------------------
Comments
Fix Request: Requesting to backport this fix to JDK 11u since it might cause of incorrect Metaspace GC behavior. The fix is low risk. We can check this change with vmTestbase tests.The JDK 13 patch applies as is to JDK 11u.
01-02-2019

Suggested fix: http://hg.openjdk.java.net/jdk/submit/rev/3f37c3d847bb This change works fine on :vmTestbase_vm_metaspace and :vmTestbase_nsk_sysdict jtreg tests.
21-01-2019

I investigated it, and I found that `minimum_desired_capacity` and `maximum_desired_capacity` in `MetaspaceGC::compute_new_size()` might exceed MaxMetaspaceSize. They shouldn't exceed MaxMetaspaceSize.
21-01-2019