From 5dca5c135470bbda3267dd63104f674a29ff81dd Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Wed, 21 Aug 2024 09:47:01 +0100 Subject: [PATCH] fix(TestProfilingMem)_: enable run with -count=2 --- profiling/heap.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/profiling/heap.go b/profiling/heap.go index fee5ab017..9e7b886e9 100644 --- a/profiling/heap.go +++ b/profiling/heap.go @@ -21,8 +21,12 @@ func WriteHeapFile(dataDir string) error { if err != nil { return err } - defer memFile.Close() //nolint: errcheck + defer func() { + memFile.Close() //nolint: errcheck + memFile = nil + }() } + runtime.GC() err = pprof.WriteHeapProfile(memFile)