typelevel / typelevel/cats-effect-testing
Global IORuntime threadpools are not closed in tests, causing a resource leak
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 194
- Forks
- 42
- Avg merge
- 5h 16m
- Merged PRs (30d)
- 1
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?
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 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.
Assessment
- Tech stack
- scala
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100