-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Avoid memory leaks in Stream methods #8367
Conversation
Huh, that's interesting. It fails when the optimizer is enabled. |
We had that before, maybe it's a different situation than the one fixed in 505b01c. I can take a look. |
9c07efd
to
51a890c
Compare
nice, the test works :-) |
what's the solution to this? |
c85daff
to
595bc2b
Compare
The |
I'll add |
The inliner replaces `return` instructions by `store`s to save the result of an inlined method. After loading that result, the local variable should be nulled out to preven memory leaks. This case was overlooked in 505b01c.
`Stream.collect/collectFirst/find` kept references to the original receiver of the call which prevented any part of the Stream from getting garbage collected as soon as possible. The previous implementation of `Stream.collect` claimed to avoid this but this only worked insofar as the resulting Stream did not hold on unnecessarily to any references to the original Stream. It still kept a reference to the original receiver while iterating over non-matching elements which can only be avoided with a tail-recursive implementation. Fixes scala/bug#11443
MiMa doesn't know about children of sealed classes either :-) added an exception. |
Phew, |
Stream.collect/collectFirst/find
kept references to the originalreceiver of the call which prevented any part of the Stream from
getting garbage collected as soon as possible.
The previous implementation of
Stream.collect
claimed to avoid thisbut this only worked insofar as the resulting Stream did not hold on
unnecessarily to any references to the original Stream. It still kept
a reference to the original receiver while iterating over non-matching
elements which can only be avoided with a tail-recursive
implementation.
Fixes scala/bug#11443