To investigate the memory issues we were experiencing in our new Scala service, we utilized a heap dump from Jxray. This revealed underutilized buffers managed by the Netty framework.
The Play WS client, relying on an older version of AsyncHttpClient, was using 16MB buffers by default, leading to excessive memory consumption. We optimized our buffer size to 4MB, reducing memory usage significantly.
Through Datadog's memory leak feature, we noticed persistent growth in the 'Heap After Full GC'. This indicated that some long-lived objects in the Old generation weren't being collected.
The Jsoniter JSON library, using a default 32KB buffer, was causing issues when handling larger data. Buffers expanded rapidly, generating temporary garbage that contributed to out-of-memory errors.
Collection
[
|
...
]