From 445a5472651cd6257af43adccdc1b002cb5f8a94 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 26 Jul 2016 20:18:16 +0200 Subject: [PATCH] Set Recycler DEFAULT_INITIAL_MAX_CAPACITY to a more sane value Motivation: We used a very high number for DEFAULT_INITIAL_MAX_CAPACITY (over 200k) which is not very relastic and my lead to very surprising memory usage if allocations happen in bursts. Modifications: Use a more sane default value of 32k Result: Less possible memory usage by default --- common/src/main/java/io/netty/util/Recycler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/main/java/io/netty/util/Recycler.java b/common/src/main/java/io/netty/util/Recycler.java index 19ca5cc34b..210f07b2fa 100644 --- a/common/src/main/java/io/netty/util/Recycler.java +++ b/common/src/main/java/io/netty/util/Recycler.java @@ -49,8 +49,7 @@ public abstract class Recycler { }; private static final AtomicInteger ID_GENERATOR = new AtomicInteger(Integer.MIN_VALUE); private static final int OWN_THREAD_ID = ID_GENERATOR.getAndIncrement(); - // TODO: Some arbitrary large number - should adjust as we get more production experience. - private static final int DEFAULT_INITIAL_MAX_CAPACITY = 262144; + private static final int DEFAULT_INITIAL_MAX_CAPACITY = 32768; // Use 32k instances as default max capacity. private static final int DEFAULT_MAX_CAPACITY; private static final int INITIAL_CAPACITY;