Skip to content

Commit 97987b1

Browse files
committed
Merge pull request #359 from Microsoft/cleanup
Wire cleanupSemanticCache
2 parents 3a0d40a + 0c9510e commit 97987b1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/services/services.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ module ts {
12991299
if (programUpToDate()) {
13001300
return;
13011301
}
1302-
1302+
13031303
var compilationSettings = hostCache.compilationSettings();
13041304

13051305
// Now, remove any files from the compiler that are no longer in the host.
@@ -1372,6 +1372,15 @@ module ts {
13721372
typeChecker = program.getTypeChecker();
13731373
}
13741374

1375+
/// Clean up any semantic caches that are not needed.
1376+
/// The host can call this method if it wants to jettison unused memory.
1377+
/// We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
1378+
function cleanupSemanticCache(): void {
1379+
if (program) {
1380+
typeChecker = program.getTypeChecker();
1381+
}
1382+
}
1383+
13751384
function dispose(): void {
13761385
if (program) {
13771386
forEach(program.getSourceFiles(),
@@ -2180,7 +2189,7 @@ module ts {
21802189
return {
21812190
dispose: dispose,
21822191
refresh: () => { },
2183-
cleanupSemanticCache: () => { },
2192+
cleanupSemanticCache: cleanupSemanticCache,
21842193
getSyntacticDiagnostics: getSyntacticDiagnostics,
21852194
getSemanticDiagnostics: getSemanticDiagnostics,
21862195
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,

0 commit comments

Comments
 (0)