Memory leak when using WriterT
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimized Scala example in the issue and compare its WriterT behavior with plain IO, then inspect the linked reproduction repository and Scastie example. Done means the repeating stream no longer retains the large mapped strings or exhibits the reported memory leak when run with WriterT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100