Skip to content

Commit 6c1f98a

Browse files
committed
JS: Update vague variable name
1 parent 759631a commit 6c1f98a

File tree

1 file changed

+8
-5
lines changed
  • javascript/extractor/lib/typescript/src

1 file changed

+8
-5
lines changed

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,11 @@ function getEnvironmentVariable<T>(name: string, parse: (x: string) => T, defaul
534534

535535
/**
536536
* Whether the memory usage was last observed to be above the threshold for restarting the TypeScript compiler.
537+
*
538+
* This is to prevent repeatedly restarting the compiler if the GC does not immediately bring us below the
539+
* threshold again.
537540
*/
538-
let isAboveReloadThreshold = false;
541+
let hasReloadedSinceExceedingThreshold = false;
539542

540543
/**
541544
* If memory usage has moved above a the threshold, reboot the TypeScript compiler instance.
@@ -545,13 +548,13 @@ let isAboveReloadThreshold = false;
545548
function checkMemoryUsage() {
546549
let bytesUsed = process.memoryUsage().heapUsed;
547550
let megabytesUsed = bytesUsed / 1000000;
548-
if (!isAboveReloadThreshold && megabytesUsed > reloadMemoryThresholdMb && state.project != null) {
551+
if (!hasReloadedSinceExceedingThreshold && megabytesUsed > reloadMemoryThresholdMb && state.project != null) {
549552
console.warn('Restarting TypeScript compiler due to memory usage');
550553
state.project.reload();
551-
isAboveReloadThreshold = true;
554+
hasReloadedSinceExceedingThreshold = true;
552555
}
553-
else if (isAboveReloadThreshold && megabytesUsed < reloadMemoryThresholdMb) {
554-
isAboveReloadThreshold = false;
556+
else if (hasReloadedSinceExceedingThreshold && megabytesUsed < reloadMemoryThresholdMb) {
557+
hasReloadedSinceExceedingThreshold = false;
555558
}
556559
}
557560

0 commit comments

Comments
 (0)