MCPcopy
hub / github.com/helm/helm / stopProfiling

Function stopProfiling

pkg/cmd/profiling.go:60–91  ·  view source on GitHub ↗

stopProfiling stops profiling CPU and memory usage. It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE environment variable.

()

Source from the content-addressed store, hash-verified

58// It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE
59// environment variable.
60func stopProfiling() error {
61 errs := []error{}
62
63 // Stop CPU profiling if it was started
64 if cpuProfileFile != nil {
65 pprof.StopCPUProfile()
66 err := cpuProfileFile.Close()
67 if err != nil {
68 errs = append(errs, err)
69 }
70 cpuProfileFile = nil
71 }
72
73 if memProfilePath != "" {
74 f, err := os.Create(memProfilePath)
75 if err != nil {
76 errs = append(errs, err)
77 }
78 defer f.Close()
79
80 runtime.GC() // get up-to-date statistics
81 if err := pprof.WriteHeapProfile(f); err != nil {
82 errs = append(errs, err)
83 }
84 }
85
86 if err := errors.Join(errs...); err != nil {
87 return fmt.Errorf("error(s) while stopping profiling: %w", err)
88 }
89
90 return nil
91}

Callers 1

newRootCmdWithConfigFunction · 0.85

Calls 2

CloseMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…