eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 722 forks source link

Mxbean gcNotification sometimes throw error while using balanced gc #16413

Closed 1a2s3d4f1 closed 1 year ago

1a2s3d4f1 commented 1 year ago

Java -version output

openjdk version "17.0.5" 2022-10-18
IBM Semeru Runtime Open Edition 17.0.5.0 (build 17.0.5+8)
Eclipse OpenJ9 VM 17.0.5.0 (build openj9-0.35.0, JRE 17 Linux amd64-64-Bit Compressed References 20221018_325 (JIT enabled, AOT enabled)
OpenJ9   - e04a7f6c1
OMR      - 85a21674f
JCL      - 32d2c409a33 based on jdk-17.0.5+8)

Summary of problem

Sometimes, using balanced gc without -Xmx and -Xms options could cause mxbean gcNotification thrown error. It could happen on windows or linux platform. I found this issue is easier happend on vitual machine(vitual box). VirtualBox_Linux_03_12_2022_13_39_53

This program is hmcl. It a game launcher. This issue can happen on minecraft too.

Diagnostic files

Launch options: java -Xgc:enableArrayletDoubleMapping -Xverbosegclog -Xgcpolicy:balanced -Xdump:none -verbose:sizes -jar HMCL-3.5.3.223.jar Option "-Xgc:enableArrayletDoubleMapping" is nessary while running hmcl with balanced gc. Use -verbose:sizes" to view memory inofmation.

  -Xmca32K        RAM class segment increment
  -Xmco128K       ROM class segment increment
  -Xmcrs200M      compressed references metadata initial size
  -Xmns8M         initial new space size
  -Xmnx735M       maximum new space size
  -Xms8M          initial memory size
  -Xmos8M         initial old space size
  -Xmox1004032K   maximum old space size
  -Xmx1004032K    memory maximum
  -Xlp:objectheap:pagesize=4K    large page size
                  available large page sizes:
                  4K
  -Xlp:codecache:pagesize=4K     large page size for JIT code cache
                  available large page sizes for JIT code cache:
                  4K
  -Xmso512K       operating system thread stack size
  -Xiss2K         java thread stack initial size
  -Xssi16K        java thread stack increment
  -Xss1M          java thread stack maximum size
  -XX:SharedCacheHardLimit=300M shared class cache size
  -Xscmx64M       shared class cache soft max size
  -Xscdmx24544K   reserved shared class cache space for class debug attributes
  -Xscminaot0K    min reserved shared class cache space for AOT
  -Xscmaxaot282300K max allowed shared class cache space for AOT
  -Xscminjitdata0K min reserved shared class cache space for JIT data
  -Xscmaxjitdata282300K max allowed shared class cache space for JIT data

HMCL(A game launcher) throw error:

[13:30:24] [org.jackhuang.hmcl.util.CrashReporter.uncaughtException/SEVERE] Uncaught exception in thread MemoryMXBean notification dispatcher
java.lang.IllegalArgumentException: committed argument cannot be less than 0
    at java.management/java.lang.management.MemoryUsage.<init>(MemoryUsage.java:109)
    at jdk.management/com.ibm.lang.management.internal.ExtendedGarbageCollectorMXBeanImpl.buildGcInfo(ExtendedGarbageCollectorMXBeanImpl.java:94)
    at jdk.management/com.ibm.lang.management.internal.MemoryNotificationThread.dispatchGCNotificationHelper(MemoryNotificationThread.java:94)
    at jdk.management/com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop(Native Method)
    at jdk.management/com.ibm.lang.management.internal.MemoryNotificationThread.run(MemoryNotificationThread.java:183)
    at java.base/java.lang.Thread.run(Thread.java:857)

Verbosegc: verbosegc.20221203.132939.2652.zip

gacholio commented 1 year ago

@dmitripivkine @amicic

dmitripivkine commented 1 year ago

@LinHu2016 FYI

LinHu2016 commented 1 year ago

Thanks @1a2s3d4f1 for reporting the issue, I will try to reproduce the issue locally and investigate the case.

1a2s3d4f1 commented 1 year ago

@LinHu2016 I reproduced this issue by click button "All Instances" on menu of hmcl when I used jconsole to get memory information. test1 verbosegc.20221206.002531.1348.zip

LinHu2016 commented 1 year ago

looks like both mxbean reporting and verbose gc log doesn't handle the case that free region count after GC is smaller than Eden region count correctly, both reporting still assume defined eden size, which could cause "reserved size" is smaller than 0.... looks like current code will use whole free regions as eden for the case, just want to confirm if it is correct behaviour before I update mxbean reporting code.