StreamOpFlag.* and OutOfMemoryError when going parall
Brian Goetz
brian.goetz at oracle.com
Wed Dec 5 19:23:55 PST 2012
> As Brian pointed out, because the limit() isn't fully lazy, this
> results in an OutOfMemoryError because actually calculating _all_
> prime numbers this way and _then_ limit the result set isn't really an
> option. Now I wonder whether I could build a better limit() version
> myself...
No, that's not exactly right. The decomposition is left-spine (so it
should compute the leftmost ones earlier) and it cancels once its found
enough. But it may well compute more than 1000.
It sounds like something else is wrong. It shouldn't OOME on such a
small problem.
More information about the lambda-dev
mailing list