GitHub user queimadus closed a discussion: Memory leak when using 
`flatMapPrefix`/`prefixAndTail` with `Concat`

When using `flatMapPrefix` or `prefixAndTail` (or any other flow that closes 
over data) followed by `concat` the accumulated portion doesn't seem to be GC'd.

I reduced a problem I found into this snippet:

```scala
val s = Source
  .repeat(())
  .map(_ => ByteString('a' * 40000))
  .take(1000000)
  .flatMapPrefix(50000) { prefix => Flow[ByteString] } 

Source.empty
  .concatAllLazy(List.tabulate(30000)(_ => s): _*)
  .runWith(Sink.ignore).onComplete(println(_))  
```

If we don't use concat, it runs fine:

```scala
  Source
    .repeat(s)
    .take(30000)
    .flatMapConcat(x => x)
    .runWith(Sink.ignore)
    .onComplete(println(_))
```

GitHub link: https://github.com/apache/pekko/discussions/1566

----
This is an automatically sent email for notifications@pekko.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@pekko.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to