-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
Do you want to request a feature or report a bug?
Bug
What happens:
- After recently updating mongoose, we've experienced a memory leak.
- When saving a document, a version-error is created and saved to
this.$__.$versionError - When creating this version error it runs a captureStacktrace command. Capturing the stack means references to it's stack (for us that included CLS, requests, etc) are retained. This is related to this nodejs issue
- As a result, the errors and their stack are not garbage collected. With many save operations this would cause our process to run out of memory
Why this didnt happen before
- In this commit the versionerror is stored in
this.$__.$versionErrorinstead ofoptions.$versionError - The options object is cleaned up after a save (see here). The
this.$__.$versionErrorhowever isnt
Workaround
- Using a post-save hook that deletes
this.$__.$versionError
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose: 5.6.3
node: v10.16.0
mongo: 3.4.1
cc @thombohlk
Fonger
Metadata
Metadata
Assignees
Labels
No labels