Add Memory profiler to profilers package

This commit is contained in:
qowevisa 2024-06-09 07:37:05 +03:00
parent a22dfc66ff
commit 1c5e2625d5

20
profilers/memory.go Normal file
View File

@ -0,0 +1,20 @@
package profilers
import (
"os"
"runtime"
"runtime/pprof"
)
func GetMemoryProfiler() {
f, err := os.Create("mem.prof")
if err != nil {
panic(err)
}
defer f.Close()
runtime.GC()
if err := pprof.WriteHeapProfile(f); err != nil {
panic(err)
}
return
}