commit 3071801e5a75dcb63b46768fcfc2dc9c43d11e2d
parent e960f1e8324812d97f534263312362555ad37f8c
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 13 Dec 2023 17:29:00 +0900
add memory profile
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/cmd/diskfs/main.go b/cmd/diskfs/main.go
@@ -11,6 +11,7 @@ import (
"net"
"os"
"os/signal"
+ "runtime"
"runtime/pprof"
"sync"
@@ -68,6 +69,15 @@ L:
}
wg.Wait()
log.Println("shutting down")
+ f, err = os.Create("mem.prof")
+ if err != nil {
+ log.Fatal("create: %v", err)
+ }
+ defer f.Close()
+ runtime.GC()
+ if err := pprof.WriteHeapProfile(f); err != nil {
+ log.Fatal("prof: %v", err)
+ }
}
func handle(ctx context.Context, wg *sync.WaitGroup, conn net.Conn, disk *diskfs.FS) {