Skip to content

Commit

Permalink
ByteBufUtil to not pool direct memory by default
Browse files Browse the repository at this point in the history
Motivation:
ByteBufUtil by default will cache DirectByteBuffer objects, and the
associated direct memory (up to 64k). In combination with the Recycler which may
cache up to 32k elements per thread may lead to a large amount of direct
memory being retained per EventLoop thread. As traffic spikes come this
may be perceived as a memory leak because the memory in the Recycler
will never be reclaimed.

Modifications:
- By default we shouldn't cache DirectByteBuffer objects.

Result:
Less direct memory consumption due to caching DirectByteBuffer objects.
  • Loading branch information
Scottmitch authored Feb 12, 2018
1 parent 7928a6f commit 108fbe5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion buffer/src/main/java/io/netty/buffer/ByteBufUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected CharBuffer initialValue() throws Exception {

DEFAULT_ALLOCATOR = alloc;

THREAD_LOCAL_BUFFER_SIZE = SystemPropertyUtil.getInt("io.netty.threadLocalDirectBufferSize", 64 * 1024);
THREAD_LOCAL_BUFFER_SIZE = SystemPropertyUtil.getInt("io.netty.threadLocalDirectBufferSize", 0);
logger.debug("-Dio.netty.threadLocalDirectBufferSize: {}", THREAD_LOCAL_BUFFER_SIZE);

MAX_CHAR_BUFFER_SIZE = SystemPropertyUtil.getInt("io.netty.maxThreadLocalCharBufferSize", 16 * 1024);
Expand Down

0 comments on commit 108fbe5

Please sign in to comment.