I am implementing a middleware between clients of the memaslap
benchmark and the memcached
server. The key size is set to 16Bytes and the value size to 1024Bytes, so the request should never exceed 2048Bytes which is MAX_PACKET_LENGTH
in the following code fragment:
ByteBuffer buffer = ByteBuffer.allocate(MAX_PACKET_LENGTH);
while(running) {
try {
buffer.clear();
socketChannel.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
....
}
It is very strange to me why after a certain amount of requests (it is never the same amount) there occurs a BufferOverflow despite I did a buffer.clear()
before.
Can anyone help me?