Skip to content
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

Prevent memory leak when using cache, fix leak test #2522

Merged
merged 3 commits into from Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rollup/index.ts
Expand Up @@ -170,7 +170,9 @@ export default function rollup(
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);

Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion test/leak/index.js
Expand Up @@ -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');
Expand Down