@@ -37,7 +37,6 @@ final class ServerTCPNIOTransport extends ReferenceCountedObject<TCPNIOTransport
3737
3838 private static final LocalizedLogger logger = LocalizedLogger .getLoggerForThisClass ();
3939 static final ServerTCPNIOTransport SERVER_TRANSPORT = new ServerTCPNIOTransport ();
40- private static final long MB = 1024 * 1024 ;
4140
4241 private ServerTCPNIOTransport () {
4342 // Prevent instantiation.
@@ -98,24 +97,8 @@ protected TCPNIOTransport newInstance() {
9897 // Enabled by default.
9998 builder .setReuseAddress (Boolean .parseBoolean (reuseAddressStr ));
10099 }
101- float heapPercent ;
102- if (Runtime .getRuntime ().maxMemory () < 1024 * MB ) {
103- // Low heap
104- heapPercent = 0.01f ;
105- } else {
106- // Compute a percentage to try to reach roughly 64Mb (big enough (tm))
107- heapPercent = 64f * MB / Runtime .getRuntime ().maxMemory ();
108- }
109100 // Force usage of PooledMemoryManager which allows to use grizzly's buffers across threads.
110- builder .setMemoryManager (new PooledMemoryManager (
111- 1024 , // Initial buffer size
112- 3 , // Number of pools (with growing factor below this give us pools of 1K, 4K, 16k buffers)
113- 4 , // Growing factor to apply on the size of the buffer polled by the next pool
114- selectorThreadCount , // Number of pool slices that every pool will stripe allocation requests across
115- heapPercent , // The percentage of the heap that this manager will use when populating the pools (5%)
116- 1f , // The percentage of buffers to be pre-allocated during MemoryManager initialization (100%)
117- true // true to use direct buffers or false to use heap buffers
118- ));
101+ builder .setMemoryManager (new PooledMemoryManager (true ));
119102
120103 final TCPNIOTransport transport = builder .build ();
121104
0 commit comments