From eae4dfca7b3f5c77c7f02a502dddf94865646461 Mon Sep 17 00:00:00 2001 From: Ted Xu Date: Tue, 9 Jul 2024 14:12:10 +0800 Subject: [PATCH] fix: reuse deserialize result to help improve memory management (#34507) Fixed #33268 The original reuse is broken by #33359 Signed-off-by: Ted Xu --- internal/storage/serde.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/storage/serde.go b/internal/storage/serde.go index a20b3aaba6861..44228e76a651e 100644 --- a/internal/storage/serde.go +++ b/internal/storage/serde.go @@ -538,8 +538,9 @@ func (deser *DeserializeReader[T]) Next() error { deser.pos = 0 deser.rec = deser.rr.Record() - // allocate new slice preventing overwrite previous batch - deser.values = make([]T, deser.rec.Len()) + if deser.values == nil || len(deser.values) != deser.rec.Len() { + deser.values = make([]T, deser.rec.Len()) + } if err := deser.deserializer(deser.rec, deser.values); err != nil { return err }