Conversation
There was a problem hiding this comment.
Bugbot free trial expires on July 29, 2025
Learn more in the Cursor dashboard.
| // 通道已满,丢弃结果并更新统计信息(已在锁内) | ||
| tw.droppedCount++ | ||
| // 将resultData放回池中 | ||
| tumblingResultPool.Put(resultData) |
There was a problem hiding this comment.
Bug: Window Trigger Memory Leak and Corruption
Improper object pool management in TumblingWindow and SlidingWindow's Trigger methods causes memory leaks and potential data corruption.
resultDataslices, retrieved from pools, are only returned when the output channel is full; successful sends to the channel leak these slices.newDataslices, also from pools, are assigned to the window's internaldatafield. This permanently holds pooled slices, preventing their return and risking data corruption if the pool reuses their underlying arrays.
Code comments acknowledge these issues but offer no resolution for proper resource return.
| } | ||
|
|
||
| // 注意:不能将result放回池中,因为调用者还在使用 | ||
| // group maps也不能立即放回池中,因为它们在result中被引用 |
There was a problem hiding this comment.
Bug: Memory Leak in Object Pool Usage
The GetResults() method suffers from an object pool memory leak. The result slice and individual group maps retrieved from sync.Pools are never returned to their respective pools. This leads to pool depletion, negating performance benefits and causing continuous new allocations, as acknowledged by the existing code comments.
Locations (1)
| } | ||
|
|
||
| // 注意:newData不能放回池中,因为它现在是sw.data | ||
| // resultData也不能放回池中,因为它可能还在输出通道中被使用 |
There was a problem hiding this comment.
Bug: Sliding Window Memory Leak
The SlidingWindow.Trigger method suffers from object pool memory leaks. Slices retrieved from sw.rowPool (newData) are assigned to sw.data but are never returned to the pool. Similarly, slices from sw.resultPool (resultData) are only returned if the output channel send fails; otherwise, they are sent via the channel but never returned to the pool. This leads to gradual pool depletion. Additionally, a comment regarding resultData's return policy is misleading.
Locations (1)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
==========================================
- Coverage 49.95% 49.86% -0.09%
==========================================
Files 45 45
Lines 11691 11755 +64
==========================================
+ Hits 5840 5862 +22
- Misses 5374 5415 +41
- Partials 477 478 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.