Replies: 1 comment 3 replies
-
When doing |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team,
in the path to understand how Netty manages the pool of memory buffers, I tried the following simple experiment:
The test essentially allocates 124MB of ByteBuf each of 8KB size.
Allocate other 8KB with ByteBuf of 512 byte each.
Free these last 8KB.
Ask to allocate 4MB in a unique ByteBuf but fails with OOM.
Ask to allocate 4MB in slices of 8KB ByteBuf but fails with OOM.
Ask to allocate 4MB in slices of 512 ByteBuf and successed.
Failure trace
The script is launched with the following JVM settings, limiting direct memory to 128MB and forcing the use of only 1 arena:
My understanding of how Netty allocates memory is by dividing the available memory in Arenas (with this formula
netty/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java
Lines 114 to 116 in 53fa91f
Each arena contains multiple chucks, which by default are 4MB wide each. Each chunk is assigned to a length size, so that 8KB ByteBuf-s are borrowed from one chunk while others (for example 2KB) are from a different chunk.
Now I've 2 questions:
Beta Was this translation helpful? Give feedback.
All reactions