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

High memory usage with jest projects #2015

Open
richardcornelissen opened this issue Oct 8, 2020 · 1 comment
Open

High memory usage with jest projects #2015

richardcornelissen opened this issue Oct 8, 2020 · 1 comment
Labels
Performance Severe performance issue

Comments

@richardcornelissen
Copy link

🐛 Bug Report

Memory usage is high when running ts-jest with jest projects.

To Reproduce

Steps to reproduce the behavior:

git clone git@github.com:richardcornelissen/ts-jest-projects-oom.git
yarn install
yarn test

You will see tests running with a high heap size.
image

Expected behavior

Much lower memory usage.

Link to repo (highly encouraged)

https://github.com/richardcornelissen/ts-jest-projects-oom

Debug log:

Too large to inline, available at https://raw.githubusercontent.com/richardcornelissen/ts-jest-projects-oom/main/ts-jest.log

envinfo

System:
    OS: macOS 10.15.7
    CPU: 3,1 GHz Dual-Core Intel Core i5
Npm packages:
    jest: 26.5.2
    ts-jest: 26.4.1
    typescript: 4.0.3

Potential cause

From snapshotting the heap and reading the logs, it looks like initializeLanguageServiceInstance (see language-service.ts) gets called for each jest project, which keeps a cache of transpiled and instrumented code in memory (memoryCache) which never gets cleared

Workaround

If you encounter this issue, using ts-jest's isolatedModules might help.
In the example repo, run yarn test:isolated-modules as an example
image

@richardcornelissen richardcornelissen added Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Oct 8, 2020
@ahnpnl
Copy link
Collaborator

ahnpnl commented Oct 8, 2020

This has been reported in #1967 , this issue is a duplicated one to that. You can check more discussion there.

@ahnpnl ahnpnl added 🐛 Bug Confirmed Bug is confirmed Performance Severe performance issue and removed Bug Report Needs Repo Need a minimium repository to reproduce the problem Needs Triage labels Oct 8, 2020
@ahnpnl ahnpnl removed 🐛 Bug Confirmed Bug is confirmed labels Oct 19, 2020
trivikr added a commit to trivikr/aws-sdk-js-v3 that referenced this issue Oct 5, 2021
trivikr added a commit to trivikr/aws-sdk-js-v3 that referenced this issue Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Severe performance issue
Projects
None yet
Development

No branches or pull requests

2 participants