How Netty’s ByteBuf Reference Counting Evolved: From Simple Counters to Parity‑Based Concurrency Safety
This article examines Netty 4.1.x’s ByteBuf reference‑counting mechanism, explains why reference counting was introduced, traces its original design, shows instruction‑level optimizations, reveals concurrency bugs in version 4.1.17, and details the clever even‑odd redesign that guarantees thread‑safe memory release while preserving high performance.
