Skip to content

Memory leaks #2394

@svalaskevicius

Description

@svalaskevicius

Hi, we've been hit by a memory leak in fs2:

lazy val catsVersion = "2.6.0"
lazy val catsEffectVersion = "3.1.0"
lazy val fs2Version = "3.0.2"

Simplest example to reproduce:

package example

import cats.effect.IOApp
import cats.effect.{ExitCode, IO}
import fs2.Stream
import fs2.Pull
import scala.concurrent.duration._

object Hello extends IOApp {

  override def run(args: List[String]): IO[ExitCode] =
    Stream
      .awakeEvery[IO](2.milli)
      .map(identity _)
      .foreach(_ => IO.unit)
      .compile
      .drain
      .as(ExitCode.Success)

}

The fs2 pull/bind etc objects keep being accumulated in memory and never freed, also, they seem to form a cycle:

2021-05-13-122215_2472x1560

Also, a colleague mentioned, that Stream.repeat method also leaks, and while I haven't looked at that, it may be related.

Needless to say, this is a rather serious issue and is a blocker for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions