Is Go profiling "always on"?
go, profiling
Solution
MemProfileRate is nonzero by default, but it's set to a rate that's low enough that it shouldn't affect most programs. It's on by default so that if a program's memory starts to balloon, there would be some data to find the problem without recompiling.
In go1.5 there will be a new `GODEBUG` flag `memprofilerate`, so it can be changed via an environment variable. Setting `memprofilerate=0` will disable memory profiling. http://tip.golang.org/pkg/runtime/
Problem
I'd like to add command line flags to my Go program to enable/disable cpu and memory profiling. CPU profiling is enabled explicitly with pprof.StartCPUProfile(). But memory profiling is not explicitly enabled. You just call pprof.WriteHeapProfile() at exit. Is there a runtime cost associated with either form of profiling if I never make those calls? And if not, does that mean that the memory profiling is basically always on?