From c6c77e6f92d2ed7e366b1d14b5318f8b3f4e4a4f Mon Sep 17 00:00:00 2001 From: Nimrod Gilboa Markevich Date: Wed, 25 May 2022 02:34:41 +0300 Subject: [PATCH] tmp: Print mem stats in api-server --- agent/main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/agent/main.go b/agent/main.go index 7feea5dbb..82bd86872 100644 --- a/agent/main.go +++ b/agent/main.go @@ -9,6 +9,7 @@ import ( "net/http" "os" "os/signal" + "runtime" "strconv" "strings" "syscall" @@ -17,6 +18,7 @@ import ( "github.com/gin-contrib/pprof" "github.com/gin-contrib/static" "github.com/gin-gonic/gin" + "github.com/struCoder/pidusage" "github.com/up9inc/mizu/agent/pkg/dependency" "github.com/up9inc/mizu/agent/pkg/entries" "github.com/up9inc/mizu/agent/pkg/middlewares" @@ -76,6 +78,18 @@ func main() { if *profiler { pprof.Register(app) + go func() { + memStats := runtime.MemStats{} + runtime.ReadMemStats(&memStats) + sysInfo, _ := pidusage.GetStat(os.Getpid()) + logger.Log.Infof( + "HeapAlloc: %d, HeapSys: %d, rss: %f", + memStats.HeapAlloc, + memStats.HeapSys, + sysInfo.Memory, + ) + time.Sleep(time.Minute) + }() } utils.StartServer(app)