Skip to content

Commit

Permalink
restrict gc disable to not serve or watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Dec 4, 2022
1 parent 2030df1 commit decf208
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/esbuild/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,16 @@ func main() {
}
}

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

0 comments on commit decf208

Please sign in to comment.