-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 on deep_cyclic_copy jest 23 #6787
Comments
@sibelius thanks for reporting - why do you think deepCyclicCopy is leaking? I see it in the stack trace but isn't that just where it runs out of memory, not necessarily what is leaking? |
it makes sense, maybe the leaking is in another part of the code I've ran in this repo as well https://github.com/graphql-compose/graphql-compose-mongoose and the heap is increasing there as well |
Can you run with |
28 tests failed with leaks on https://github.com/graphql-compose/graphql-compose-mongoose is there any way to get more information about it? |
I've found this about memory leak on mongoose Automattic/mongoose#2874 (comment): mongoose.connections.forEach(connection => {
const modelNames = Object.keys(connection.models)
modelNames.forEach(modelName => {
delete connection.models[modelName]
})
const collectionNames = Object.keys(connection.collections)
collectionNames.forEach(collectionName => {
delete connection.collections[collectionName]
})
})
const modelSchemaNames = Object.keys(mongoose.modelSchemas)
modelSchemaNames.forEach(modelSchemaName => {
delete mongoose.modelSchemas[modelSchemaName]
}) I've added this to afterAll jest hook, but it did not worked well |
it could be related to this comment #1456 (comment) |
I am facing the same problema and what I am seeing here is the same message:
|
we added this #6787 (comment) to afterAll hook, it solved most part of memory leak from mongoose and we solved the other leak part mocking |
Mongoose maintainer here. This is not a memory leak, its global state that you need to clean up in your tests. In general, using global state in tests is an anti-pattern. If you want to create a new model for each test, use |
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. |
🐛 Bug Report
The heap usage keeps increasing when using mongoose
To Reproduce
https://github.com/entria/graphql-dataloader-boilerplate has a simple config that has this issue, but it only crashes when there are a lot of tests (as the memory keeps increasing).
this happens with and without --runInBand option
Expected behavior
the memory heap decreases after a jest
Link to repl or repo (highly encouraged)
https://github.com/entria/graphql-dataloader-boilerplate
Run
npx envinfo --preset jest
Paste the results here:
Below is a print of some tests in a private repo:
And here the crash when the memory heap is not enough anymore:
I think this is related to #6738
The text was updated successfully, but these errors were encountered: