-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JvmMonitor: Handle more generation and collector scenarios. #12469
Conversation
ZGC on Java 11 only has a generation 1 (there is no 0). This causes a NullPointerException when trying to extract the spacesCount for generation 0. In addition, ZGC on Java 15 has a collector number 2 but no spaces in generation 2, which breaks the assumption that collectors always have same-numbered spaces. This patch adjusts things to be more robust, enabling the JvmMonitor to work properly for ZGC on both Java 11 and 15.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I notice that we're using the JStatData APIs provided in the The JDK itself provides public management API to allow us to access these counters.
I think we can use these APIs to replace the old one so that we:
BTW, I'm not saying we need to do this in this PR. |
@FrankChen021 That sounds like it would be an excellent enhancement. I'm not sure why the current code uses JStatData instead of the MXBeans. IMO we could merge this patch now, and then switch to MXBeans when someone has the opportunity to write & test a new version of the JvmMonitor. |
ZGC on Java 11 only has a generation 1 (there is no 0). This causes
a NullPointerException when trying to extract the spacesCount for
generation 0. In addition, ZGC on Java 15 has a collector number 2
but no spaces in generation 2, which breaks the assumption that
collectors always have same-numbered spaces.
This patch adjusts things to be more robust, enabling the JvmMonitor
to work properly for ZGC on both Java 11 and 15.