Skip to content

Commit decf208

Browse files
committed
restrict gc disable to not serve or watch mode
1 parent 2030df1 commit decf208

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cmd/esbuild/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,16 @@ func main() {
292292
}
293293
}
294294

295-
if !isServeOrWatch && nonFlagCount <= 1 {
295+
if !isServeOrWatch {
296296
// If this is not a long-running process and there is at most a single
297297
// entry point, then disable the GC since we're just going to allocate
298298
// a bunch of memory and then exit anyway. This speedup is not
299299
// insignificant. We don't do this when there are multiple entry points
300300
// since otherwise esbuild could unnecessarily use much more memory
301301
// than it might otherwise need to process many entry points.
302-
debug.SetGCPercent(-1)
302+
if nonFlagCount <= 1 {
303+
debug.SetGCPercent(-1)
304+
}
303305
} else if !isStdinTTY && !isWatchForever {
304306
// If stdin isn't a TTY, watch stdin and abort in case it is closed.
305307
// This is necessary when the esbuild binary executable is invoked via

0 commit comments

Comments
 (0)