INNER CODE UNIT · Go
stopProfile
cilium/tetragon · cmd/tetragon/main.go:148
func stopProfile() {
if option.Config.MemProfile != "" {
log.Info("Stopping mem profiling", "file", option.Config.MemProfile)
f, err := os.Create(option.Config.MemProfile)
if err != nil {
logger.Fatal(log, "could not create memory profile", "file", option.Config.MemProfile, logfields.Error, err)
}
defer f.Close()
// get up-to-date statistics
runtime.GC()
if err := pprof.WriteHeapProfile(f); err != nil {
logger.Fatal(log, "could not write memory profile", logfields.Error, err)
}
}
if option.Config.CpuProfile != "" {
log.Info("Stopping cpu profiling", "file", option.Config.CpuProfile)
pprof.StopCPUProfile()
}