mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
fix: release memory after pop from heap (#42482)
issue: #42481 Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
parent
490827974d
commit
fc010e44a8
@ -121,6 +121,7 @@ func (h *pendingBroadcastTaskArray) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil // release the memory of underlying array.
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ func (impl *flusherComponents) buildDataSyncServiceWithRetry(ctx context.Context
|
||||
logger.Warn("fail to append flush message for segments that not created by streaming service into wal", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
impl.logger.Info("append flush message for segments that not created by streaming service into wal", zap.Stringer("msgID", appendResult.MessageID), zap.Uint64("timeTick", appendResult.TimeTick))
|
||||
logger.Info("append flush message for segments that not created by streaming service into wal", zap.Stringer("msgID", appendResult.MessageID), zap.Uint64("timeTick", appendResult.TimeTick))
|
||||
return nil
|
||||
}, retry.AttemptAlways()); err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -86,6 +86,7 @@ func (h *ackers) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil // release the memory of underlying array.
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ func (h *uncommittedTxnInfoOrderByMessageID) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil // release the memory of underlying array.
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ func (h *immutableMessageHeap) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil // release the memory of underlying array.
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
@ -60,6 +60,8 @@ func (h *heapArray[E]) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
var zero E
|
||||
old[n-1] = zero // release the memory of underlying array.
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
@ -94,6 +96,8 @@ func (h *objectHeapArray[O, E]) Pop() interface{} {
|
||||
old := h.objects
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
var zero O
|
||||
old[n-1] = zero // release the memory of underlying array.
|
||||
h.objects = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user