aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2019-02-01 06:25:07 +0700
committerShulhan <ms@kilabit.info>2019-02-01 06:25:07 +0700
commit3d2f34daa8ed4068cb3785859044c6e9cd66be6b (patch)
tree1129cf7e88812e9eb4c9726573953674a032edf0
parent85187dcbd873332cfb099d5e14375cb3e6ce8722 (diff)
downloadrescached-3d2f34daa8ed4068cb3785859044c6e9cd66be6b.tar.xz
cmd/rescached: write heap profile when debugging runtime
While at it, make the debugRuntime only run if debug value in options is greater than or equal to 2.
-rw-r--r--cmd/rescached/main.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/rescached/main.go b/cmd/rescached/main.go
index 1e91b9d..2672f07 100644
--- a/cmd/rescached/main.go
+++ b/cmd/rescached/main.go
@@ -55,8 +55,11 @@ func debugRuntime(rcd *rescached.Server) {
memHeap := debug.NewMemHeap()
for range ticker.C {
+ debug.WriteHeapProfile("rescached", true)
+
memHeap.Collect()
println(rcd.CachesStats())
+
fmt.Printf("= rescached.MemHeap: {RelHeapAlloc:%d RelHeapObjects:%d DiffHeapObjects:%d}\n",
memHeap.RelHeapAlloc, memHeap.RelHeapObjects,
memHeap.DiffHeapObjects)
@@ -79,7 +82,7 @@ func main() {
go handleSignal(rcd)
- if debug.Value >= 1 {
+ if debug.Value >= 2 {
go debugRuntime(rcd)
}