https://github.com/kirillgroshkov/datastore-jest-leak-repro
Minimal repro for datastore+jest memory leak
https://github.com/kirillgroshkov/datastore-jest-leak-repro
datastore jest memory-leak
Last synced: 3 months ago
JSON representation
Minimal repro for datastore+jest memory leak
- Host: GitHub
- URL: https://github.com/kirillgroshkov/datastore-jest-leak-repro
- Owner: kirillgroshkov
- Created: 2019-03-30T14:16:08.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-30T14:17:24.000Z (over 6 years ago)
- Last Synced: 2025-07-13T05:53:23.246Z (3 months ago)
- Topics: datastore, jest, memory-leak
- Language: JavaScript
- Size: 57.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Jest + Datastore memory leak
## Working test
`src/working/working.test.js` is the minimal example *without* Datastore library.
Test is duplicated 500 times and ran with flags `--maxWorkers=1 --logHeapUsage --detectOpenHandles --detectLeaks`
to log heap usage and detect leaks.`log_working.txt` shows that it does not leak - memory usage stays consistent.
## Leaking test
By require'ing [@google-cloud/datastore](https://github.com/googleapis/nodejs-datastore) package (just doing `require`,
nothing else) - it leaks memory.`src/leaking/leaking.test.js` illustrates that.
Duplicated 500 times.
When ran with flags `--maxWorkers=1 --logHeapUsage --detectOpenHandles` it shows increasing memory usage. Some garbage
collection happens on they way, but not all memory is freed.`log_leaking.txt` shows that. With 500 tests it ends with ~1800Mb memory, or ~30Mb not freed memory per 1 test.
When ran with additional flag `--detectLeaks` - Jest reports leakage (confirming the log).