Golang pprof heap profile is empty

Q:

When you use `go tool pprof` get heap data, profile is empty.

A:

The default sampling rate is 1 sample per 512KB of allocated memory.

So If you application use little memory, the profiling can't sampling any data.

You can change runtime.MemProfileRate to reduce sampling rate.

The easy way is add Environment Variables GODEBUG="memprofilerate=1", before run you application.

[via]

[via]

[via]

原文地址:https://www.cnblogs.com/eshizhan/p/5672976.html