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

perf: clean hostCache to avoid extending lifetime of script snapshots #3331

Merged
merged 1 commit into from
Jun 1, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,10 @@ module ts {
}
}

// hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
// It needs to be cleared to allow all collected snapshots to be released
hostCache = undefined;

program = newProgram;

// Make sure all the nodes in the program are both bound, and have their parent
Expand All @@ -2483,6 +2487,7 @@ module ts {
return;

function getOrCreateSourceFile(fileName: string): SourceFile {
Debug.assert(hostCache !== undefined);
// The program is asking for this file, check first if the host can locate it.
// If the host can not locate the file, then it does not exist. return undefined
// to the program to allow reporting of errors for missing files.
Expand Down