# go tool pprof returns an empty debug/pprof/heap profile


Fetching `debug/pprof/heap` with `go tool pprof` gave an empty profile.

The reason is that Go samples memory allocations by default once every 512KB (`runtime.MemProfileRate` defaults to `512 * 1024`). If the process doesn't allocate that much during the window, no samples are taken at all and the profile stays empty.

The fix is to shrink the sampling interval, most easily through the `GODEBUG` environment variable:

```bash
export GODEBUG="memprofilerate=1"
```

`1` means sample on every allocation. That costs real performance, so only turn it on while you're debugging.

Source: <https://www.cnblogs.com/eshizhan/p/5672976.html>

