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

Release reference to HttpStreamsServerHandler.lastRequest when possible #161

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

georgepearman
Copy link
Contributor

When using idleTimeout configuration in a play application, the HttpStreamsServerHandler keeps a reference to lastRequest, and lastRequest can be relatively large (10kb). When there are many open idle connections, lastRequest heap usage can add up, even though the data is not used (lastRequest will be reassigned to a new value when serving the next request).

This change sets lastRequest to null to allow the HttpRequest to be GC'd even if HttpStreamsServerHandler is kept in the heap.

To test I deployed this change in my play application and observed the heap dump before/after the change. The idle connections take a lot less heap space now. Existing unit tests in HttpStreamsTest continue to pass.

When using idleTimeout configuration in a play application, the
HttpStreamsServerHandler keeps a reference to lastRequest, and
lastRequest can be relatively large (10kb).  When there are many open
idle connections, lastRequest heap usage can add up, even though the
data is not used (lastRequest will be reassigned to a new value when
serving the next request).

This change sets lastRequest to null to allow the HttpRequest to be GC'd
even if HttpStreamsServerHandler is kept in the heap.
@mkurz
Copy link
Member

mkurz commented Oct 12, 2022

Hm... The test suite is failing, can you take a look? https://github.com/playframework/netty-reactive-streams/actions/runs/3232393934/jobs/5292957489

@georgepearman
Copy link
Contributor Author

My interpretation of the test that failed is it's unrelated to my change. Could you please rerun the github checks (I dont seem to have permission) to confirm?

Copy link
Member

@mkurz mkurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Makes sense to me!

@mkurz mkurz merged commit deae75c into playframework:main Oct 12, 2022
@mkurz
Copy link
Member

mkurz commented Oct 12, 2022

@georgepearman
Copy link
Contributor Author

Thank you!

@mkurz
Copy link
Member

mkurz commented Oct 17, 2022

FYI: This is part of Play 2.8.18 which is now available on Maven Central.

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 this pull request may close these issues.

2 participants