From 8fb2c68722898801adbe3933933a488379fc8688 Mon Sep 17 00:00:00 2001 From: rookisbusy Date: Sat, 8 Apr 2023 01:39:48 +0800 Subject: [PATCH] fix: chat.js not begin with zero --- hub/route/server.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hub/route/server.go b/hub/route/server.go index 47cb78398..d8124d330 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -250,11 +250,19 @@ func memory(w http.ResponseWriter, r *http.Request) { t := statistic.DefaultManager buf := &bytes.Buffer{} var err error + first := true for range tick.C { buf.Reset() + inuse := t.Memory() + // make chat.js begin with zero + // this is shit var,but we need output 0 for first time + if first { + inuse = 0 + first = false + } if err := json.NewEncoder(buf).Encode(Memory{ - Inuse: t.Memory(), + Inuse: inuse, OSLimit: 0, }); err != nil { break