@@ -1511,10 +1511,14 @@ export function createProgram(createProgramOptions: CreateProgramOptions): Progr
1511
1511
* @returns A 'Program' object.
1512
1512
*/
1513
1513
export function createProgram ( rootNames : readonly string [ ] , options : CompilerOptions , host ?: CompilerHost , oldProgram ?: Program , configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program ;
1514
- export function createProgram ( rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program {
1515
- const createProgramOptions = isArray ( rootNamesOrOptions ) ? createCreateProgramOptions ( rootNamesOrOptions , _options ! , _host , _oldProgram , _configFileParsingDiagnostics ) : rootNamesOrOptions ; // TODO: GH#18217
1516
- const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion } = createProgramOptions ;
1517
- let { oldProgram } = createProgramOptions ;
1514
+ export function createProgram ( _rootNamesOrOptions : readonly string [ ] | CreateProgramOptions , _options ?: CompilerOptions , _host ?: CompilerHost , _oldProgram ?: Program , _configFileParsingDiagnostics ?: readonly Diagnostic [ ] ) : Program {
1515
+ let _createProgramOptions = isArray ( _rootNamesOrOptions ) ? createCreateProgramOptions ( _rootNamesOrOptions , _options ! , _host , _oldProgram , _configFileParsingDiagnostics ) : _rootNamesOrOptions ; // TODO: GH#18217
1516
+ const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion, host : createProgramOptionsHost } = _createProgramOptions ;
1517
+ let { oldProgram } = _createProgramOptions ;
1518
+ // Stop referencing these objects to ensure GC collects them.
1519
+ _createProgramOptions = undefined ! ;
1520
+ _rootNamesOrOptions = undefined ! ;
1521
+
1518
1522
for ( const option of commandLineOptionOfCustomType ) {
1519
1523
if ( hasProperty ( options , option . name ) ) {
1520
1524
if ( typeof options [ option . name ] === "string" ) {
@@ -1569,7 +1573,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
1569
1573
tracing ?. push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
1570
1574
performance . mark ( "beforeProgram" ) ;
1571
1575
1572
- const host = createProgramOptions . host || createCompilerHost ( options ) ;
1576
+ const host = createProgramOptionsHost || createCompilerHost ( options ) ;
1573
1577
const configParsingHost = parseConfigHostFromCompilerHostLike ( host ) ;
1574
1578
1575
1579
let skipDefaultLib = options . noLib ;
0 commit comments