From 461960f0213d214b4cae4a1a41550c927620ed85 Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Sat, 16 Mar 2024 20:26:35 -0700 Subject: [PATCH] colexecargs: deeply reset monitor registry on Reset Given some recent issues we've had with leaks around memory monitors, it seems prudent to deeply reset the slice of monitors that is stored in the monitor registry object and is reused. Note that we haven't seen any evidence of leaks related to this registry, but this change might make things easier for GC, so seems worth it. Release note: None --- pkg/sql/colexec/colexecargs/monitor_registry.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/sql/colexec/colexecargs/monitor_registry.go b/pkg/sql/colexec/colexecargs/monitor_registry.go index e6c5038af70a..b4e5efa3e5b4 100644 --- a/pkg/sql/colexec/colexecargs/monitor_registry.go +++ b/pkg/sql/colexec/colexecargs/monitor_registry.go @@ -246,8 +246,12 @@ func (r *MonitorRegistry) Close(ctx context.Context) { // Reset prepares the registry for reuse. func (r *MonitorRegistry) Reset() { - // There is no need to deeply reset the memory monitoring infra slices - // because these objects are very tiny in the grand scheme of things. + for i := range r.accounts { + r.accounts[i] = nil + } + for i := range r.monitors { + r.monitors[i] = nil + } r.accounts = r.accounts[:0] r.monitors = r.monitors[:0] }