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

Memory leak in PerContextThreadWrapper #949

Closed
plesingr-aeb opened this issue Dec 21, 2023 · 1 comment · Fixed by #965
Closed

Memory leak in PerContextThreadWrapper #949

plesingr-aeb opened this issue Dec 21, 2023 · 1 comment · Fixed by #965
Milestone

Comments

@plesingr-aeb
Copy link

plesingr-aeb commented Dec 21, 2023

There is problem with the registerStopEvent in PerThreadContext$PerContextThreadWrapper. The registration keeps a reference to the wrapper in both the monitored object (this) and the cleanup action (this.instances). That causes an eternal reference to the wrapper, together with all the cached values.

It was probably originally intended to monitor the PerThreadContext object. But the whole registration is not necessary at all, because when the wrapper gets collectable (as it happens via PerThreadContext.shutdown()), the contained instances map is going to be released, too.

The whole problem is reproducible with Jersey clients and XML payload:
JerseyMemoryTest.txt

@avpinchuk
Copy link
Contributor

@plesingr-aeb, thank you for detailed explanation

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

Successfully merging a pull request may close this issue.

3 participants