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

OOM using bufferSliding #3882

Closed
jsfwa opened this issue Jun 26, 2020 · 4 comments · Fixed by #3892
Closed

OOM using bufferSliding #3882

jsfwa opened this issue Jun 26, 2020 · 4 comments · Fixed by #3892
Labels
bug Something isn't working stream ZIO Stream

Comments

@jsfwa
Copy link

jsfwa commented Jun 26, 2020

ZIO version: 1.0.0-RC21

Hi guys, simple reproducible OOM via bufferSliding:

 ZStream
      .repeat(Foo(1L))
      .bufferSliding(1)
      .runDrain
      .exitCode

image

image

@iravid
Copy link
Member

iravid commented Jun 26, 2020

Thank you for reporting (and minimizing!) @jsfwa. We'll look into this.

@iravid iravid added bug Something isn't working stream ZIO Stream labels Jun 26, 2020
@jsfwa
Copy link
Author

jsfwa commented Jun 27, 2020

Just checked, the leak is in this recursive call https://github.com/zio/zio/blob/master/streams/shared/src/main/scala/zio/stream/ZStream.scala#L434
changed it to

Take.fromPull(as).tap(take => queue.offer(take)).doWhile(_ != Take.end).unit

And looks like it solved the problem, but not sure about the correctness of this approach

@iravid
Copy link
Member

iravid commented Jun 27, 2020

@jsfwa Interesting. Would you like to open a PR with the fix and we can verify it there?

@narma
Copy link
Contributor

narma commented Jun 27, 2020

Hey! I'm @jsfwa colleague, and he asked me to create PR because he away from the computer for a weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stream ZIO Stream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants