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

Close any open selectors when tearing down a runtime. #3222

Merged
merged 1 commit into from
Sep 22, 2015

Conversation

bbrowning
Copy link
Contributor

This fixes a runtime leak in embedded scenarios where a runtime may
never get garbage collected because it has a thread blocked on a
select call. This leak exists in JRuby 1.7.x as well, but for some
reason I'm seeing it more often in JRuby 9.x when running TorqueBox 3
integration tests. Perhaps there is more IO that uses select in 9.x
than 1.7.x?

Here's a gist with a fairly simple reproducer and results on 1.7.21, 9.0.0.0, and 9.0.1.0-SNAPSHOT with this patch applied - https://gist.github.com/bbrowning/3cbb3901d4facd7fc99f

@mkristian
Copy link
Member

@bbrowning does it makes sense to turn the reproducer from the gist into a test case ?

@bbrowning
Copy link
Contributor Author

Perhaps - my only hesitation was I didn't see an easy way to get around needing a sleep in the test case to make sure the runtimes have all actually been torn down by the time we check for threads hanging around.

@kares
Copy link
Member

kares commented Aug 5, 2015

+1 for doing this on jruby-1_7 as well

bbrowning added a commit to torquebox/torquebox that referenced this pull request Aug 10, 2015
All integration tests pass as long as first apply
jruby/jruby#3222 and build JRuby from
source. Once that PR is accepted upstream everything should be good
without needing a custom build of JRuby.

This branch of TorqueBox 3 is usable with JRuby 9.0.0.0 out of the
box, but you will run into memory leaks over time as an application is
redeployed until the issue referenced above is fixed.
This fixes a runtime leak in embedded scenarios where a runtime may
never get garbage collected because it has a thread blocked on a
select call. This leak exists in JRuby 1.7.x as well, but for some
reason I'm seeing it more often in JRuby 9.x when running TorqueBox 3
integration tests. Perhaps there is more IO that uses select in 9.x
than 1.7.x?
@bbrowning
Copy link
Contributor Author

I've rebased this on top of JRuby master and turned the reproducer into a test case per the suggestion by @mkristian.

@mkristian mkristian merged commit ce7d531 into jruby:master Sep 22, 2015
@enebo enebo modified the milestone: Non-Release May 25, 2016
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.

None yet

4 participants