title: How to find a root cause of the following netty error: io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s)
body: <p>I've experienced the following exception thrown from the pipeline responsible for sending data to a TCP client.</p>
  
  <pre><code>2017-03-02T18:00:53,749 [epollEventLoopGroup-3-1] ERROR [ExceptionHandler - null] - Unknown exception
  io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 117440512, max: 119537664)
      at io.netty.util.internal.PlatformDependent.incrementMemoryCounter(PlatformDependent.java:613) ~[netty-common-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:567) ~[netty-common-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:699) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:688) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:237) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PoolArena.allocate(PoolArena.java:213) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PoolArena.allocate(PoolArena.java:141) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:262) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:179) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:170) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:131) ~[netty-buffer-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:73) ~[netty-transport-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.channel.RecvByteBufAllocator$DelegatingHandle.allocate(RecvByteBufAllocator.java:124) ~[netty-transport-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:950) [netty-transport-native-epoll-4.1.2.Final-linux-x86_64.jar:4.1.2.Final]
      at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe$1.run(AbstractEpollChannel.java:359) [netty-transport-native-epoll-4.1.2.Final-linux-x86_64.jar:4.1.2.Final]
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:400) [netty-common-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:306) [netty-transport-native-epoll-4.1.2.Final-linux-x86_64.jar:4.1.2.Final]
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:805) [netty-common-4.1.2.Final.jar:4.1.2.Final]
      at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:145) [netty-common-4.1.2.Final.jar:4.1.2.Final]
      at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60] 
  </code></pre>
  
  <p>The component that reports this bug sends data in chunks. The chunk size differs from the range of 512b to 15kb</p>
  
  <p>Could you please advice me regarding the best tools and techniques to find the root cause of this error.</p>