File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments