Closed
Description
Environment
- version: nodejs v14.0.0-pre
- platform: mac
What steps will reproduce the bug?
// main.js
const count = 100
for (var i = 0; i < count; i++) {
try {
require('./error-module.json')
// require('./error-module.js')
}catch (e) {}
}
debugger
// error-module.json
{
json: "syntax errors, no double quotes"
}
// error-module.js
throw new Error('any module syntax error')
What is the expected behavior?
Run main.js , expected error module completely clear and willl be garbage collected.
What do you see instead?
It is still retained by parent module now.
Additional information
I discovered this in the process of solving the my service memory leak problem, which logic like:each request load the module for some reason, unfortunately module is syntax error.
I checked the source code of nodejs and found that when the module error was occurs, the golbal module cache and the resolve path cache were deleted, but the module in parent.children array was not deleted.
I solved the problem, preparing my first PR for nodejs, and looking forward to your review.
Metadata
Metadata
Assignees
Labels
No labels