From a9128e8200ab6b54965b556de5067de928e07f8b Mon Sep 17 00:00:00 2001 From: ekexium Date: Mon, 18 Mar 2024 14:55:17 +0800 Subject: [PATCH] fix: check mem != nil before calling Mem() (#1236) Signed-off-by: ekexium --- internal/unionstore/pipelined_memdb.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/unionstore/pipelined_memdb.go b/internal/unionstore/pipelined_memdb.go index cd72c8698..69b39ba22 100644 --- a/internal/unionstore/pipelined_memdb.go +++ b/internal/unionstore/pipelined_memdb.go @@ -411,7 +411,14 @@ func (p *PipelinedMemDB) onMemChange() { // Mem returns the memory usage of MemBuffer. func (p *PipelinedMemDB) Mem() uint64 { - return p.memDB.Mem() + p.flushingMemDB.Mem() + var mem uint64 + if p.memDB != nil { + mem += p.memDB.Mem() + } + if p.flushingMemDB != nil { + mem += p.flushingMemDB.Mem() + } + return mem } type errIterator struct {