fs2 icon indicating copy to clipboard operation
fs2 copied to clipboard

Memory leak when using WriterT

Open mrdziuban opened this issue 3 years ago • 2 comments

I'm experiencing a memory leak on the latest v3.2.7 when using an effect type that includes WriterT. I've put together a repository to reproduce the issue and to demonstrate that it doesn't happen when using plain IO -- https://github.com/mrdziuban/fs2-WriterT-memory

Here's a minimized example to reproduce the issue:

import cats.data.WriterT
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import fs2.Stream

val longString = "a" * (1024 * 1024)

Stream[WriterT[IO, Unit, *], Unit](()).repeat.map(_ => longString).compile.drain.run.unsafeRunSync()

Also in a scastie here: https://scastie.scala-lang.org/mrdziuban/o8jjvkgOQVOwYnJ1A831dQ/4

mrdziuban avatar May 26 '22 16:05 mrdziuban

@mrdziuban Good morning, and thanks for reporting this. One clarification: when you mention that it happens in the latest version v3.2.7, does that mean it does not happen in the previous version v3.2.5? I will try to git bisect this.

diesalbla avatar Jun 26 '22 11:06 diesalbla

Hi @diesalbla, thanks for looking into this! Sorry for the confusion in my wording -- I just tested and it happens in v3.2.5, v3.0.0, and v2.5.11 (latest in the 2.x series), so I don't think it's a new issue.

mrdziuban avatar Jun 27 '22 17:06 mrdziuban