Skip to content

Commit 86d9398

Browse files
committed
clean hostCache to avoid extending lifetime of script snapshots
1 parent 9b12fab commit 86d9398

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/services/services.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,6 +2487,10 @@ module ts {
24872487
}
24882488
}
24892489

2490+
// hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point.
2491+
// It needs to be cleared to allow all collected snapshots to be released
2492+
hostCache = undefined;
2493+
24902494
program = newProgram;
24912495

24922496
// Make sure all the nodes in the program are both bound, and have their parent
@@ -2495,6 +2499,7 @@ module ts {
24952499
return;
24962500

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

0 commit comments

Comments
 (0)