Why you (don't) want to write you own memory buffer recycler?
summary
A custom object pool for recycled byte buffers replaces per-request string and array allocations in a log-to-Elasticsearch plugin, using Jackson to write into buffers and Netty primitives for comparison. Using a Netty composite buffer would avoid most work, but the implemented recycler cuts accumulated freed memory from roughly 80GB → 11GB, lowers GC pressure (average pauses from ~5.5ms to ~3–4ms for 1KB logs), and scales to about 5,000 messages/s in tests.
AI-written summary · about
chapters (22)
- 0:00Intro
- 1:15Lock for JT elasticsearch
- 1:30Object pooling
- 1:43Birthday party example
- 2:08Batch drug delivery
- 3:15Architecture
- 4:33High memory allocation
- 6:23Allocation triggers
- 7:12Demo
- 8:00Resize strategies
- 8:35Reallife example
- 8:51The architecture
- 10:18The perfect buffer
- 11:05Writing from scratch
- 11:47Creating your own buffer
- 12:22Expectations
- 13:48Overhead
- 16:00Flat Graph Results
- 18:16Scaling Up
- 18:40Results
- 18:59Was it worth it
- 20:22Can you handle 100k allocations per second








