Skip to content

Commit

Permalink
fix #750: enable gc for watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 4, 2021
1 parent f346d8a commit 3a706d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

* Fix memory leak with watch mode when using the CLI ([#750](https://github.com/evanw/esbuild/issues/750))

This release fixes a memory leak when using `--watch` from the CLI (command-line interface). When esbuild was in this state, every incremental build resulted in more memory being consumed. This problem did not affect users of the JS API or Go API, only users of the CLI API.

The problem was that the GC (garbage collector) was disabled. Oops. This is done by default for speed when you use esbuild via the CLI, which makes sense for most CLI use cases because the process is usually short-lived and doesn't need to waste time cleaning up memory. But it does not make sense for flags that cause esbuild to be a long-running process.

Previously the only exception to this rule was the `--serve` flag. When I added watch mode, I forgot to enable GC for the `--watch` flag too. With this release, the GC is enabled for both the `--serve` and the `--watch` flags so esbuild should no longer leak memory in watch mode.

* Special-case certain syntax with `--format=esm` ([#749](https://github.com/evanw/esbuild/issues/749))

You can now no longer use the following syntax features with the `esm` output format:
Expand Down
4 changes: 2 additions & 2 deletions cmd/esbuild/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ func main() {
exitCode = cli.Run(osArgs)
}
} else {
// Don't disable the GC if this is a long-running server process
// Don't disable the GC if this is a long-running process
isServe := false
for _, arg := range osArgs {
if arg == "--serve" || strings.HasPrefix(arg, "--serve=") {
if arg == "--serve" || arg == "--watch" || strings.HasPrefix(arg, "--serve=") {
isServe = true
break
}
Expand Down

0 comments on commit 3a706d4

Please sign in to comment.