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

Clearing inflight along with streams to avoid memory leak #30

Merged
merged 1 commit into from
Jun 23, 2020

Conversation

kanishkatn
Copy link
Contributor

@kanishkatn kanishkatn commented Jun 23, 2020

We came across a memory leak issue during a loadtest. Session.inflight was taking around 150MB of space in memory and it was never cleaned up.

We forked the repo and fixed it by clearing inflight along with the streams. We've tested it under load as well.

I'd be happy to help to get the PR merged. Let me know if you need anything from me,

This fixes #29

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -690,6 +690,7 @@ func (s *Session) incomingStream(id uint32) error {
// Backlog exceeded! RST the stream
s.logger.Printf("[WARN] yamux: backlog exceeded, forcing connection reset")
delete(s.streams, id)
delete(s.inflight, id)
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be necessary, but it can't hurt.

@@ -708,6 +709,7 @@ func (s *Session) closeStream(id uint32) {
}
}
delete(s.streams, id)
delete(s.inflight, id)
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

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.

Memory leak in Session
2 participants