From 2e145dbacb06ca524df2e761c985ae22ecd4ac47 Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Tue, 19 Dec 2023 14:28:47 +0800 Subject: [PATCH] g3-histogram: fix mem usage --- lib/g3-histogram/src/keeping.rs | 1 + lib/g3-histogram/src/rotating.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/g3-histogram/src/keeping.rs b/lib/g3-histogram/src/keeping.rs index 89a39664..8424cad6 100644 --- a/lib/g3-histogram/src/keeping.rs +++ b/lib/g3-histogram/src/keeping.rs @@ -103,6 +103,7 @@ where for v in buf.iter().take(count) { let _ = self.inner.record(v.as_u64()); } + buf.clear(); stats.update(self.inner()); } }); diff --git a/lib/g3-histogram/src/rotating.rs b/lib/g3-histogram/src/rotating.rs index c4f102dd..cd6b661d 100644 --- a/lib/g3-histogram/src/rotating.rs +++ b/lib/g3-histogram/src/rotating.rs @@ -110,6 +110,7 @@ where for v in buf.iter().take(n) { let _ = self.inner.record(v.as_u64()); } + buf.clear(); } _ = rotate_interval.tick() => { if !self.inner.is_empty() {