From 7f1720b3dc636e8556fd7fdcbcd2030ded1fe367 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Fri, 10 Apr 2026 16:40:08 +0200 Subject: [PATCH] eth/txtracker: compact FIFO order slice to prevent memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit order = order[1:] reslices without releasing the backing array. After N total insertions the array retains N hashes (32 bytes each) but only the last maxTracked are live. On a long-running node processing ~100 txs/s this leaks ~275 MB/day. Compact by copying to a fresh array when capacity exceeds 2×maxTracked. --- eth/txtracker/tracker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eth/txtracker/tracker.go b/eth/txtracker/tracker.go index f2afae4dd4..83d94af33f 100644 --- a/eth/txtracker/tracker.go +++ b/eth/txtracker/tracker.go @@ -137,6 +137,11 @@ func (t *Tracker) NotifyAccepted(peer string, hashes []common.Hash) { t.order = t.order[1:] delete(t.txs, oldest) } + // Compact the backing array when it grows too large. Reslicing + // with order[1:] doesn't free earlier slots in the array. + if cap(t.order) > 2*maxTracked { + t.order = append([]common.Hash(nil), t.order...) + } } // GetAllPeerStats returns a snapshot of per-peer inclusion statistics.