Documentation ¶
Overview ¶
Package cmemprof profiles C memory allocations (malloc, calloc, realloc, etc.)
Importing this package in a program will replace malloc, calloc, and realloc with wrappers which will sample allocations and record them to a profile.
To use this package:
f, _ := os.Create("cmem.pprof") var profiler cmemprof.Profile profiler.Start(500) // ... do allocations profile, err := profiler.Stop()
Building this package on Linux requires a non-standard linker flag to wrap the alloaction functions. For Go versions < 1.15, cgo won't allow the flag so it has to be explicitly allowed by setting the following environment variable when building a program that uses this package:
export CGO_LDFLAGS_ALLOW="-Wl,--wrap=.*"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Profile ¶
type Profile struct { // SamplingRate is the value, in bytes, such that an average of one // sample will be recorded for every SamplingRate bytes allocated. An // allocation of N bytes will be recorded with probability min(1, N / // SamplingRate). SamplingRate int // contains filtered or unexported fields }
Profile provides access to a C memory allocation profiler based on instrumenting malloc, calloc, and realloc.