Skip to content

Commit

Permalink
SI-6409 Stream flatMap leaks memory if mapper returns many empties
Browse files Browse the repository at this point in the history
Added Scaladoc explaining that this is necessary behavior, but closed ticket as wontfix.
  • Loading branch information
Ichoran committed May 30, 2014
1 parent da2896c commit 2ef1932
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/library/scala/collection/immutable/Stream.scala
Expand Up @@ -97,6 +97,14 @@ import scala.language.implicitConversions
* If, on the other hand, there is nothing holding on to the head (e.g. we used
* `def` to define the `Stream`) then once it is no longer being used directly,
* it disappears.
*
* - Note that some operations, including [[drop]], [[dropWhile]],
* [[flatMap]] or [[collect]] may process a large number of intermediate
* elements before returning. These necessarily hold onto the head, since
* they are methods on `Stream`, and a stream holds its own head. For
* computations of this sort where memoization is not desired, use
* `Iterator` when possible.
*
* {{{
* // For example, let's build the natural numbers and do some silly iteration
* // over them.
Expand Down

0 comments on commit 2ef1932

Please sign in to comment.