killme2008 / xmemcached

High performance, easy to use multithreaded memcached client in java.
http://fnil.net/xmemcached
Apache License 2.0
757 stars 280 forks source link

XMemcached network layout exception: java.lang.OutOfMemoryError: Direct buffer memory #119

Open sfxnmadu opened 4 years ago

sfxnmadu commented 4 years ago

Hello, We use memcached v2.4.6, and are currently getting the below error:

09-06-2020 09:36:34,934 ERROR MemcachedHandler:128 - XMemcached network layout exception: java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:694) at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:241) at sun.nio.ch.IOUtil.read(IOUtil.java:195) at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) at com.google.code.yanf4j.nio.impl.NioTCPSession.readFromBuffer(NioTCPSession.java:190) at com.google.code.yanf4j.nio.impl.AbstractNioSession.onRead(AbstractNioSession.java:184) at com.google.code.yanf4j.nio.impl.AbstractNioSession.onEvent(AbstractNioSession.java:324) at com.google.code.yanf4j.nio.impl.SocketChannelController.dispatchReadEvent(SocketChannelController.java:54) at com.google.code.yanf4j.nio.impl.NioController.onRead(NioController.java:150) at com.google.code.yanf4j.nio.impl.Reactor.dispatchEvent(Reactor.java:310) at com.google.code.yanf4j.nio.impl.Reactor.run(Reactor.java:177)

I reckon this might be similar to the issue in raised here, but I will appreciate specific insights on how to address this problem for this type of OOME - Direct buffer memory. And yes, we do use the xmemcached client as a singleton instance.

Thank you

killme2008 commented 3 years ago

It seems that you may have too many connections ,every connection will keep an read direct buffer. You can increase the max direct buffer size or decrease the connection pool size.