-
Notifications
You must be signed in to change notification settings - Fork 529
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
Memory leak in v3.4.4 for cats.effect.CallbackStack #3359
Comments
Very concerning. Do you have any more details on what reproduces this? A heap dump would be the most helpful thing, or some subset of code. In lieu of that, are you doing anything interesting with Deferred? |
Are there long-lived |
Yeah this is absolutely true (regarding the linked structure not being removed). Basically it trades off some memory in the |
Sadly I think Ember would like a word with you there. Connecting via JMX I can see the number of From a very quick glance at the Ember server code, I would guess that |
Meant to say that I was hitting that hello world server in a tight loop. From what I can see, we leak 4 |
This is VERY awesome @TimWSpence. Can you get a heap dump so we can be sure about where the ownership is on these objects? |
@TimWSpence Did the leak in Ember start with the last couple of releases, or was it there from before? |
Sure! Here's one after a couple of minutes of hammering it in a tight loop with |
I only observed it today so I'm afraid I can't be sure. I don't have time now I'm afraid but next week I can downgrade the http4s version for that reproduction and see if it still leaks. From what I've seen I believe that it should but obviously worth confirming! |
Somewhat simpler reproduction with FS2: import cats.effect.{ExitCode, IO}
import cats.effect.IOApp
import fs2.Stream
object Example extends IOApp {
final override def run(args: List[String]): IO[ExitCode] = {
IO.deferred[Either[Throwable, Unit]].flatMap { p =>
val s = Stream.eval(IO { () }).repeat.interruptWhen(p)
s.compile.drain.as(ExitCode.Success)
}
}
} FS2 3.4.0; does not leak with Cats Effect 3.4.2, but does leak with 3.4.4. There is an |
Yeah I think that's exactly what's happening. I'm pondering if there's a way to adjust CallbackStack to be more self cleaning, rather than leaving the remnants of the structure in place. |
Reproducer:
If you run this with a concurrent |
Thanks for reporting, I opened #3935. |
CallbackStack leaks badly in v3.4.4
After downgrading to v3.4.2 the issue disappeared.
The text was updated successfully, but these errors were encountered: