IssueRaiser

Module caching memory leak

## πŸ› Bug Report <!-- A clear and concise description of what the bug is. --> `ts-jest` seems to cache compiled modules over and over again, creating a memory leak. There is a basline suite of tests using just `jest` on [`main`](https://github.com/willsoto/jest-repro) ## To Reproduce Steps to reproduce the behavior: 1. `git clone git@github.com:willsoto/jest-repro.git` (note the branch is `ts-jest-memory-leak`) 2. `npm ci` 3. Run any of the [test scripts](https://github.com/willsoto/jest-repro/blob/ts-jest-memory-leak/package.json#L7-L9) to see memory usage increasing in a way that is indicative of a memory leak. You can run [`npm run test:force-gc`](https://github.com/willsoto/jest-repro/blob/ts-jest-memory-leak/package.json#L10) to see memory usage when a garbage collection is forced. ## Expected behavior <!-- A clear and concise description of what you expected to happen. --> Modules should be cached once for the duration of the test run or allowed to be garbage collected after the test suite has completed. ## Link to repo (highly encouraged) <!-- Please provide either a minimal repository either on GitHub or GitLab. Issues without a reproduction link are likely to stall. --> https://github.com/willsoto/jest-repro/tree/ts-jest-memory-leak ## Debug log: <!-- You can activate the debug logger by setting the environment variable TS_JEST_LOG=ts-jest.log before running tests. The output of the logger will be in **ts-jest.log** in CWD, paste it in the below section:

Posted by willsoto on Sep 18, 2020, 5:04 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (Software)

Module caching memory leak

willsotoSep 18, 2020, 5:04 PM

## πŸ› Bug Report <!-- A clear and concise description of what the bug is. --> `ts-jest` seems to cache compiled modules over and over again, creating a memory leak. There is a basline suite of tests using just `jest` on [`main`](https://github.com/willsoto/jest-repro) ## To Reproduce Steps to reproduce the behavior: 1. `git clone git@github.com:willsoto/jest-repro.git` (note the branch is `ts-jest-memory-leak`) 2. `npm ci` 3. Run any of the [test scripts](https://github.com/willsoto/jest-repro/blob/ts-jest-memory-leak/package.json#L7-L9) to see memory usage increasing in a way that is indicative of a memory leak. You can run [`npm run test:force-gc`](https://github.com/willsoto/jest-repro/blob/ts-jest-memory-leak/package.json#L10) to see memory usage when a garbage collection is forced. ## Expected behavior <!-- A clear and concise description of what you expected to happen. --> Modules should be cached once for the duration of the test run or allowed to be garbage collected after the test suite has completed. ## Link to repo (highly encouraged) <!-- Please provide either a minimal repository either on GitHub or GitLab. Issues without a reproduction link are likely to stall. --> https://github.com/willsoto/jest-repro/tree/ts-jest-memory-leak ## Debug log: <!-- You can activate the debug logger by setting the environment variable TS_JEST_LOG=ts-jest.log before running tests. The output of the logger will be in **ts-jest.log** in CWD, paste it in the below section:

Comments (0)

No comments yet. Start the discussion.

Comment on this issue