From 72c0961071a29ab41e011b59bc50046c04b4d21e Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Sat, 14 Sep 2019 01:53:04 +0200 Subject: [PATCH] Force a gc before printing diagnostics Use this together with `node --expose-gc` to get more stable results --- src/tsc/tsc.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index fc75e28d504..2e837a09594 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -322,6 +322,10 @@ namespace ts { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics) { statistics = []; + + // @ts-ignore + if (typeof gc === "function") { gc(); } + const memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program));