Fix unbounded StringBuilder retention in ThreadLocal (memory leak) by anuq · Pull Request #391 · elastic/ecs-logging-java
getMessageStringBuilder() called setLength(0) which resets the logical length but never shrinks the internal char[] buffer. In thread-pool environments, a single large trace permanently bloats the buffer for that thread's lifetime, causing cumulative heap pressure. Add a capacity threshold check (8 KB) that discards oversized buffers and replaces them with fresh instances, while still reusing normally-sized buffers for zero-allocation steady state. Fixes elastic#381
SylvainJuge
added
bug
and removed triage
Issues and PRs that need to be triagedlabels
Mar 31, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters