Memory accumulated in netty PoolChunk
Asked Answered
M

2

9

Hi i'm trying to understand why so memory consumption in my app so i have downloaded a heapdump with visualjvm and then have analysed it with eclipse mat. It have found the following problem:

One instance of "io.netty.buffer.PoolChunk" loaded by "jdk.internal.loader.ClassLoaders$AppClassLoader @ 0x7f04ba5b0" occupies 16,793,832 (32.78 %) bytes. The memory is accumulated in one instance of "byte[]" loaded by "<system class loader>".

Could anybody give me some advice on how to fix this issue? What data to look and search for?

My first try was to set -Dio.netty.allocator.type=unpooled param, this have removed this problem suspect related to bytes, but introduced others 2 related to class loaders.

Regardsenter image description here

Mezereum answered 20/10, 2020 at 19:46 Comment(6)
were you able to solve this issue?Wartburg
Yep, this was not an issue as explained below. It is how netty allocates memory for ByteBuf when using pool ByteBufAllocator.Mezereum
But how did you solve it?Yokoyokohama
How this issue was solved?Demotic
to disable that behaviour you could play with "-Dio.netty.allocator.type=unpooled",Mezereum
@Mezereum You mentioned that -Dio.netty.allocator.type=unpooled resolved the problem related to bytes but introduced another 2 related to class loaders. What problems with class loaders did you face exactly?Granger
I
7

Netty uses a pooled ByteBufAllocator by default which allocates memory in "chunks". That what you see here. So it basically allocates a chunk and then slice out memory of this chunk when it needs memory. Once cant fullfill the memory need a new chunk is allocated and so on.

Indreetloire answered 21/10, 2020 at 8:44 Comment(0)
M
6

Adding -Dio.netty.allocator.type=unpooled showed significant reduction in the memory

regarding performance both with and unpooled and pooled performed similar in our case

but little spike in GC - but overall unpooled had better response time

Ma answered 21/3, 2022 at 12:22 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.