Skip to content

Commit 7f26e33

Browse files
author
tac0turtle
committed
fix
1 parent 36378a4 commit 7f26e33

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sequencers/single/queue.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,21 @@ func (bq *BatchQueue) Next(ctx context.Context) (*coresequencer.Batch, error) {
9393
return &coresequencer.Batch{Transactions: nil}, nil
9494
}
9595

96-
batch := bq.queue[bq.head]
97-
bq.queue[bq.head] = coresequencer.Batch{} // Release memory for the dequeued element
98-
bq.head++
96+
batch := bq.queue[bq.head]
97+
bq.queue[bq.head] = coresequencer.Batch{} // Release memory for the dequeued element
98+
bq.head++
9999

100100
// Compact when head gets too large to prevent memory leaks
101101
// Only compact when we have significant waste (more than half processed)
102102
// and when we have a reasonable number of processed items to avoid
103103
// frequent compactions on small queues
104104
if bq.head > len(bq.queue)/2 && bq.head > 100 {
105105
remaining := copy(bq.queue, bq.queue[bq.head:])
106-
// Zero out the rest of the slice to allow GC to reclaim memory
106+
// Zero out the rest of the slice to release memory
107107
for i := remaining; i < len(bq.queue); i++ {
108108
bq.queue[i] = coresequencer.Batch{}
109109
}
110-
// Shrink the slice
111110
bq.queue = bq.queue[:remaining]
112-
// Reset head to 0
113111
bq.head = 0
114112
}
115113

0 commit comments

Comments
 (0)