Skip to content
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

Remove duplicate System.gc() in test #18335

Closed
llxia opened this issue Oct 23, 2023 · 6 comments · Fixed by #18339
Closed

Remove duplicate System.gc() in test #18335

llxia opened this issue Oct 23, 2023 · 6 comments · Fixed by #18339
Labels

Comments

@llxia
Copy link
Contributor

llxia commented Oct 23, 2023

Some tests call GC twice.

https://github.com/eclipse-openj9/openj9/blob/fadb895178d06504a9e0ff7d6d8963879cb45a28/test/functional/Valhalla/src/org/openj9/test/lworld/ValueTypeTests.java#L357..%23L358

This is no longer needed in the tests (see #18044). We should clean it up and call System.gc() once.

FYI @dmitripivkine

@llxia llxia added comp:test good first issue Good for newcomers labels Oct 23, 2023
@0scvr
Copy link

0scvr commented Oct 23, 2023

Sign me up, please. I would like to try this issue :)

@flooxo
Copy link
Contributor

flooxo commented Oct 24, 2023

I would also love to work on the issue :)

@llxia
Copy link
Contributor Author

llxia commented Oct 24, 2023

@flooxo
Copy link
Contributor

flooxo commented Oct 24, 2023

Thanks, I'll fix them as well.
Sometimes there are also duplicate System.runFinalization(); after System.gc();. I'm not sure, can those duplicates be removed as well?

System.runFinalization();
System.runFinalization();

@llxia
Copy link
Contributor Author

llxia commented Oct 24, 2023

re #18335 (comment), @pshipton @TobiAjila Do you happen to know why we call System.runFinalization(); twice and can we remove one?

@tajila
Copy link
Contributor

tajila commented Oct 24, 2023

We've needed to call gc() twice because J9 doesn't always respect it the first time. Calling it twice guarantees that at least 1 GC occurs. This is no longer required in the latest JDKs

Do you happen to know why we call System.runFinalization(); twice and can we remove one?

Sometimes finalizable objects are created as a result of running finalizers. Calling it twice provides a better guarantee that all finalizable objects are cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants