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

Fix Enumerator fiber leaks #6021

Merged
merged 1 commit into from Feb 17, 2020
Merged

Fix Enumerator fiber leaks #6021

merged 1 commit into from Feb 17, 2020

Conversation

headius
Copy link
Member

@headius headius commented Jan 7, 2020

This PR will include commits to reduce the chance of Enumerator#next fibers leaking.

The original issue is #6004.

So far most of the leaks appear to be caused by combining Enumerator::Lazy with Enumerator#next, since many lazy paths construct new Lazy instances in such a way that they are hard-referenced by the eventual fiber.

Lazy enumerators still may leak in the presence of Enumerator#next
calls, but this at least isolates the instantiating Lazy from the
newly-created Lazy, avoiding a backreference that might keep the
original object alive.

Given a test as shown in jruby#6004 that spins up many Lazy instances,
this patch appears to work well. It did not appear to fix the
reported leaks in that issue, however.

Example code that leaked before but is stable with this patch:

```ruby
while true
  [1,2,3].lazy.reject {|x| x < 3 }.next
  JRuby.gc
end
```
@headius headius added this to the JRuby 9.2.10.0 milestone Jan 7, 2020
@headius headius merged commit c9e84f0 into jruby:master Feb 17, 2020
5 checks passed
@headius
Copy link
Member Author

@headius headius commented Feb 17, 2020

In the interest of improving things for 9.2.10 I have merged this. There's still known leaks in lazy enumerators and the root cause of #6004 remains elusive but it is a step forward.

@headius headius deleted the enumerator_leaks branch Feb 17, 2020
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

1 participant