From 569a76269f1578470d4c7ae7f009aa504384df49 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 22 Oct 2018 14:46:10 -0400 Subject: [PATCH 1/2] Delete rawInputOptions.cache to prevent memory leak --- src/rollup/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rollup/index.ts b/src/rollup/index.ts index 0778b468051..cc6b223a90d 100644 --- a/src/rollup/index.ts +++ b/src/rollup/index.ts @@ -168,9 +168,11 @@ export default function rollup( const graph = new Graph(inputOptions, curWatcher); curWatcher = undefined; - + // remove the cache option from the memory after graph creation (cache is not used anymore) + const useCache = rawInputOptions.cache !== false; delete inputOptions.cache; + delete rawInputOptions.cache; timeStart('BUILD', 1); @@ -377,7 +379,7 @@ export default function rollup( }); } - const cache = rawInputOptions.cache === false ? undefined : graph.getCache(); + const cache = useCache ? graph.getCache() : undefined; const result: RollupSingleFileBuild | RollupBuild = { cache, watchFiles: Object.keys(graph.watchFiles), From f545e250f20f69a156ecd229cb469d8ed6ad4519 Mon Sep 17 00:00:00 2001 From: Kyle Cutler Date: Mon, 22 Oct 2018 18:27:23 -0400 Subject: [PATCH 2/2] Fix leak test --- test/leak/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/leak/index.js b/test/leak/index.js index e2e463fe860..692f2a8816e 100644 --- a/test/leak/index.js +++ b/test/leak/index.js @@ -18,7 +18,7 @@ function run() { }) .then(bundle => { weak(bundle, onCollect); - cache = bundle.cache; + cache = bundle; global.gc(); if (shouldCollect && !isCollected) { throw new Error('Memory leak detected');