Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHeapProfilerBackoff is the default setting for the time to wait between heap dumps when hitting threshold in seconds DefaultHeapProfilerBackoff = time.Second * 30 )
Functions ¶
This section is empty.
Types ¶
type HeapProfiler ¶
type HeapProfiler struct {
// contains filtered or unexported fields
}
HeapProfiler is used to start a ticker that periodically checks if heap memory consumption exceed the thresholdFraction, if so the heap gets dumped to a file in Directory subject to Backoff.
func NewHeapProfiler ¶
func NewHeapProfiler(thresholdFraction float64, limitBytes uint64, directory string, backoff time.Duration) *HeapProfiler
NewHeapProfiler creates a new instance of HeapProfiler setting the given values. It appends a subdirectory to the directory to prevent acidental deletion of user files. If 0 is provides as limitBytes the limitBytes is set to 1, thus the heap dump will always run. backoff limits the maximum frequency of creating heap dumps
func (*HeapProfiler) DumpHeapOnThreshhold ¶
func (p *HeapProfiler) DumpHeapOnThreshhold(ctx context.Context, interval time.Duration)
DumpHeapOnThreshhold runs for as long as ctx is valid, checking heap usage with the given interval. Maximum frequency of creating heap dumps is limited by the configured backoff.