mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-21 13:34:26 +02:00
fix: close CPU profile file after stopping profiling (#9000)
The file handle from os.Create(cpuProfile) was passed to pprof.StartCPUProfile but never closed in the OnInterrupt handler. The block and mutex profile files are correctly closed, but the main CPU profile file was leaked. Add f.Close() after pprof.StopCPUProfile() to prevent the file descriptor leak. Co-authored-by: easonysliu <easonysliu@tencent.com>
This commit is contained in:
1 parent
c249eb5a8b
commit
a04c9c7dde
1 file changed
+1
@@ -34,6 +34,7 @@ func SetupProfiling(cpuProfile, memProfile string) {
|
||||
pprof.StartCPUProfile(f)
|
||||
OnInterrupt(func() {
|
||||
pprof.StopCPUProfile()
|
||||
f.Close()
|
||||
|
||||
// write block pprof
|
||||
blockF, err := os.Create(cpuProfile + ".block")
|
||||
|
||||
Reference in new issue
Block a user