Add Memory profiler to profilers package
This commit is contained in:
parent
a22dfc66ff
commit
1c5e2625d5
20
profilers/memory.go
Normal file
20
profilers/memory.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user