From a04c9c7ddef29e6700acb16312d8e388565e3321 Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Thu, 9 Apr 2026 13:13:02 +0800 Subject: [PATCH] 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 --- weed/util/grace/pprof.go | 1 + 1 file changed, 1 insertion(+) diff --git a/weed/util/grace/pprof.go b/weed/util/grace/pprof.go index ad1b1de393..ddd0b44755 100644 --- a/weed/util/grace/pprof.go +++ b/weed/util/grace/pprof.go @@ -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")