-
Notifications
You must be signed in to change notification settings - Fork 728
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
Add stronger guarantees to System.gc() #18044
Conversation
jenkins test sanity alinux64 jdk21 |
jenkins test sanity alinux64 jdk21 |
Finalization has been deprecated for many releases - it seems odd that the JCL would rely on unspecified and completely unreliable behaviour. |
jenkins compile win jdk8 |
@gacholio I had to add an explicit |
jenkins test sanity alinux64 jdk21 |
1 similar comment
jenkins test sanity alinux64 jdk21 |
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.
This is no longer valid. You will need to reacquire VM access and exit the VM properly.
|
Also note the ifdefs in the native - those should probably be mirrored in the JVM call. |
I suggest
and
|
Also note that this doesn't really fix anything - the finalizers themselves run on another thread, so there's no guarantee that any finalization has taken place when the JVM function / native method returns. @dmitripivkine Please correct me if |
The idea of |
Does this actually mean that all existing finalizers, and any that are created during the call will be processed? The queue would technically be empty while the finalizer was processing the last object in the queue. |
I see your point, I will check. |
The JCL code expects that when System.GC() is called a GC occurs and finalizable objects are finalized. Historically, J9 has never provided this guarantee. We have often had to modify tests to ensure a GC is triggered at the appropriate time. Increasingly, we are finding that more and more tests rely on this behaviour, and most importantly, core JCL code now relies on this behaviour. This PR ensures that a call to System.gc() triggers a GC and runs finalization. Signed-off-by: tajila <[email protected]>
jenkins test sanity alinux64 jdk21 |
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.
Regardless of Dmitri's investigation, this is the best we can do (if there are any edge cases they'll be in the GC code). The VM access changes are not strictly necessary, in that atomic-free is currently tolerant of mistakes, but I'd rather see the right thing done, particularly in these cases where the guts of the work are potentially large.
The failure was
I believe this is a known issue |
jenkins test sanity alinux64 jdk21 |
mmFuncs->j9gc_modron_global_collect(currentThread); | ||
mmFuncs->j9gc_modron_global_collect(currentThread); |
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.
Perhaps a comment is warranted here explaining why j9gc_modron_global_collect()
is run twice?
Created a doc issue eclipse-openj9/openj9-docs#1161 |
The JCL code expects that when System.GC() is called a GC occurs and finalizable objects are finalized. Historically, J9 has never provided this guarantee. We have often had to modify tests to ensure a GC is triggered at the appropriate time. Increasingly, we are finding that more and more tests rely on this behaviour, and most importantly, core JCL code now relies on this behaviour. This PR ensures that a call to System.gc() triggers a GC and runs finalization.