Use a heap buffer from the allocator because it doesn't seem to cause OOME anymore
This commit is contained in:
parent
3fe9a58f41
commit
665d022e82
@ -18,7 +18,6 @@ package io.netty.channel.socket.oio;
|
||||
import io.netty.buffer.BufType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelException;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
@ -183,21 +182,19 @@ public class OioDatagramChannel extends AbstractOioMessageChannel
|
||||
@Override
|
||||
protected int doReadMessages(MessageBuf<Object> buf) throws Exception {
|
||||
int packetSize = config().getReceivePacketSize();
|
||||
// TODO: Use alloc().heapBuffer(..) but there seems to be a memory-leak, need to investigate
|
||||
ByteBuf buffer = Unpooled.buffer(packetSize);
|
||||
ByteBuf buffer = alloc().heapBuffer(packetSize);
|
||||
boolean free = true;
|
||||
|
||||
try {
|
||||
int writerIndex = buffer.writerIndex();
|
||||
tmpPacket.setData(buffer.array(), writerIndex + buffer.arrayOffset(), packetSize);
|
||||
|
||||
tmpPacket.setData(buffer.array(), buffer.arrayOffset(), packetSize);
|
||||
socket.receive(tmpPacket);
|
||||
|
||||
InetSocketAddress remoteAddr = (InetSocketAddress) tmpPacket.getSocketAddress();
|
||||
if (remoteAddr == null) {
|
||||
remoteAddr = remoteAddress();
|
||||
}
|
||||
DatagramPacket packet = new DatagramPacket(buffer.writerIndex(writerIndex + tmpPacket.getLength())
|
||||
.readerIndex(writerIndex), remoteAddr);
|
||||
|
||||
DatagramPacket packet = new DatagramPacket(buffer.writerIndex(tmpPacket.getLength()), remoteAddr);
|
||||
buf.add(packet);
|
||||
free = false;
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user