avoid memory leak in v8 ICs after parsing and building modules

This commit is contained in:
Tobias Koppers 2021-03-25 14:52:12 +01:00
parent 2696446edf
commit 87b67a920d
2 changed files with 7 additions and 0 deletions

View File

@ -749,6 +749,9 @@ class NormalModule extends Module {
}
},
(err, result) => {
// Cleanup loaderContext to avoid leaking memory in ICs
loaderContext._compilation = loaderContext._compiler = loaderContext._module = loaderContext.fs = undefined;
if (!result) {
return processResult(
err || new Error("No result from loader-runner processing"),

View File

@ -942,6 +942,10 @@ class JavascriptParser extends Parser {
.setRange(expr.range);
}
});
this.hooks.finish.tap("JavascriptParser", () => {
// Cleanup for GC
cachedExpression = cachedInfo = undefined;
});
};
tapEvaluateWithVariableInfo("Identifier", expr => {
const info = this.getVariableInfo(