Skip to content
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 with just expect('a').toBe('a') 23 times in a file #10467

Closed
Garethp opened this issue Aug 30, 2020 · 3 comments
Closed

Memory Leak with just expect('a').toBe('a') 23 times in a file #10467

Garethp opened this issue Aug 30, 2020 · 3 comments

Comments

@Garethp
Copy link

Garethp commented Aug 30, 2020

🐛 Bug Report

Jest appears to be leaking memory for no discernible reason. Just having expect('a').toBe('a') 23 times in a file with nothing else in the repository is enough to cause a leak

To Reproduce

Steps to reproduce the behavior:

  • Have a file with 23 instances of expect('a').toBe('a')
  • Copy that file 10 times
  • Run those tests with --expose-gc, --runInBand and --logHeapUsage

Expected behavior

Memory should stay consistent and not leak.

Link to repl or repo (highly encouraged)

There's a repository to help reproduce it here

envinfo

  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  Binaries:
    Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.1/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
  npmPackages:
    jest: ^26.4.2 => 26.4.2 
@jaredjj3
Copy link

jaredjj3 commented Sep 8, 2020

I have made a similar sample repo that produced similar results (see #7874): jest-memory-leak-demo.

@SimenB
Copy link
Member

SimenB commented Mar 3, 2022

Forcing GC like mentioned in #7874 (comment) stabilizes the memory usage.

Very odd 22 vs 23 expects changes anything, but I'm guessing it triggers some heuristic within v8 that triggers some extra caching

@SimenB SimenB closed this as completed Mar 3, 2022
@github-actions
Copy link

github-actions bot commented Apr 3, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants