Global IORuntime threadpools are not closed in tests, causing a resource leak

Open
#452 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
scala

Research direction

Start by tracing how test suites obtain IORuntime.global and how sbt creates classloaders across test runs and submodules. Compare the resource lifetime of that global runtime with the cost of creating runtimes per suite. Done means repeated test runs no longer retain threadpools or eventually exhaust memory, without an unacceptable test-running slowdown.

Written by the indexing model from the issue text.

Description

This library uses IORuntime.global for tests, which causes it to never close the threadpools that are created by this global IORuntime. Combined with sbt creating a new classloader for every test run and every submodule, this results in a lot of IORuntimes and threadpools being created and never cleaned up. Eventually, it causes sbt to run of out memory after a number of test runs, especially in projects with many submodules.

I'm not sure what the best approach would be to avoid this issue, as creating a new IORuntime in every test suite will probably slow down running tests?

Dominant language
Scala
Stars
194
Forks
42
Avg merge
5h 16m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from typelevel/cats-effect-testing

All issues in typelevel/cats-effect-testing

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.