diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-06-25 13:32:32 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-06-25 13:32:32 +0200 |
commit | cb9d5ce8f6bdcbfd175ce624450851bfc5edd727 (patch) | |
tree | 32d51273d0bc5f0b7f40b73abdde17f0ecee848c /src/library | |
parent | 1c0b48da8dfa124eb762620c8cb803a9079b7c81 (diff) | |
parent | 2ef193215972321820fcb115b50be4da37d328eb (diff) | |
download | scala-cb9d5ce8f6bdcbfd175ce624450851bfc5edd727.tar.gz scala-cb9d5ce8f6bdcbfd175ce624450851bfc5edd727.tar.bz2 scala-cb9d5ce8f6bdcbfd175ce624450851bfc5edd727.zip |
Merge pull request #3805 from Ichoran/issue/6409
SI-6409 Stream flatMap leaks memory if mapper returns many empties
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/immutable/Stream.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 60de147477..d3ff5e8abf 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -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. |