-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Motivation
The current Recyclers implementation is forked from an old version of Netty's Recycler.
Netty has since made significant improvements, including:
- PR #11858: Complete rewrite removing WeakOrderQueue
- PR #9394: Fix reclaimSpace bug
- PR #11996: Avoid recycling to terminated threads
The current implementation can cause memory leaks in cross-thread scenarios
due to unbounded accumulation in WeakOrderQueue.
Modification
Sync the Recycler implementation from Netty 4.1.69+, which:
- Removes WeakOrderQueue entirely
- Uses simple MPSC queue for thread-local pooling
- Eliminates cross-thread memory leak issues
Result
Memory leak in Recyclers is fundamentally fixed.
Netty Recycler change history
40196a6305 Rewrite and simplify Recycler (#11858) -- 2021-11-26 ⭐
55cdaa75ad Try to not recycle objects back to terminated threads (#11996) -- 2021-12-14
98a3a0c0cb Recycler.WeakOrderQueue drop Object hasBeenRecycled (#11402)
dde82f62f0 Fix bug in Recycler with racing calls to recycle (#11037)
909e7c9c29 Add option to configure recycler delayed queue drop ratio (#10251)
94f3930850 Recycler availableSharedCapacity slowly exhausted (#9394) -- 2019-07-22
6cd5e8b0ca Reduce default capacity from 32k to 4k -- 2018-02-09