You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2025/02/07 14:34:09 UTC
(skywalking-banyandb) 01/01: Use a combination to get in-use memory
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch memory
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 4137883e32ee249cff84e5efcc222e24d710607a
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Fri Feb 7 22:32:24 2025 +0800
Use a combination to get in-use memory
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
banyand/protector/protector.go | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/banyand/protector/protector.go b/banyand/protector/protector.go
index 6cb7acd3..e1beff1e 100644
--- a/banyand/protector/protector.go
+++ b/banyand/protector/protector.go
@@ -174,10 +174,19 @@ func (m *Memory) Serve() run.StopNotify {
return
case <-ticker.C:
samples := []metrics.Sample{
- {Name: "/memory/classes/total:bytes"},
+ {Name: "/memory/classes/heap/objects:bytes"},
+ {Name: "/memory/classes/heap/stacks:bytes"},
+ {Name: "/memory/classes/metadata/mcache/inuse:bytes"},
+ {Name: "/memory/classes/metadata/mspan/inuse:bytes"},
+ {Name: "/memory/classes/metadata/other:bytes"},
+ {Name: "/memory/classes/os-stacks:bytes"},
+ {Name: "/memory/classes/other:bytes"},
}
metrics.Read(samples)
- usedBytes := samples[0].Value.Uint64()
+ var usedBytes uint64
+ for _, sample := range samples {
+ usedBytes += sample.Value.Uint64()
+ }
atomic.StoreUint64(&m.usage, usedBytes)