Hugo watcher increasing memory usage

I observed Hugo watcher increasing its memory footprint the more changes I make. For example, it went from 245mb to 1.4GB. Is this expected?

hugo v0.164.0-ce2470e7012b5ab5fc4e10ebe4027e9f8d9e00dc linux/amd64 BuildDate=2026-07-06T16:39:30Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.26.3"
github.com/webmproject/libwebp="v1.6.0"

We use memory when rebuilding, yes. How much depends on a number of factors, e.g. what you change. I think you need to watch this “memory footprint” over time to see the real behaviour. It should go down when Go’s garbage collector kicks in.

What you can try is:

  • “hugo server --poll 5s” (or something) and see if that changes things.

Next:

  • Try “HUGO_MEMORYLIMIT=1 hugo server --poll 5s --logLevel info”

Memorylimit 1GB should force a more aggressive cache eviction strategy and you should see some related log messages on cache resizing.

I have this code in ~/.bashrc. I will monitor with the poll command and see. Though the increase is gradual (hours) rather than at once. Yesterday, I was making a partial for single page, trying different iterations.

# Cap Hugo's internal page/template cache to 3GB, preventing it from eating system RAM
hugo() {
  HUGO_MEMORYLIMIT=3 command hugo "$@"
}

Today with hugo server --poll 5s, I watched the RAM go from around 345MB to 1.3GB in 50 minutes. Most changes were config/template related.

Even worse with 163.3. Config changes it jumped in minutes! HUGO_MEMORYLIMIT=1 hugo server --poll 5s --logLevel info.

What exactly do you mean by RAM in the above statement? There’s a big difference between total allocated memory (where this would be normal) and current allocated memory for a given process (which may or may not be normal; the Go garbage collector lives it’s one live and HUGO_MEMORYLIMIT is just a threshold where Hugo will make objects available for GC). But this is impossible for me to reason about just looking at your numbers.

PC RAM. Any config changes, even a few, makes the hugo watcher jump from 300MB to 1GB and above.