netty-socketio icon indicating copy to clipboard operation
netty-socketio copied to clipboard

OutOfMemory issue

Open Maxinim opened this issue 8 years ago • 7 comments
trafficstars

Hi there,

I'm working on developping my application using netty-socketio, but it seems to always finish with an out of memory error. If i anayze the heap dump, I see that the culprits are netty buffers. See attached heap dump dominator tree in Eclipse MAT.

The main problem is io.netty.buffer.PoolArena$HeapArena. You can see inside some exchanged messages in the PoolChunk byte array : {'join' {'agent': true....

Is there a way to limit the space used by netty, or telling it not to store messages, or to store them somewhere else ? Could you help me with this memory "leak" (not sure it's a leak, may be something i don't do correctly)?

hprof_analysis

Maxinim avatar Oct 20 '17 13:10 Maxinim

@Maxinim you may want to take a look at this Netty issue or this one also as they mention a way to change Netty's default allocator, along with some suggested JVM parameters.

pablojr avatar Oct 20 '17 14:10 pablojr

@pablojr Thanks for the info. I'll try the ChannelConfig tip, but I don't know how to set this on Netty-socketio. I'll have to search. By the way, this bug is linked to the memory store used, or it will happen whatever the store used ?

I'd like to destroy sessions also on disconnection, but I don't know how to do this.

Maxinim avatar Oct 20 '17 16:10 Maxinim

@pablojr (or anyone), I don't seem to see any reference to ChannelConfig in netty-socketio. Does soemone know how to configure this in netty-socketio server ?

Maxinim avatar Oct 20 '17 16:10 Maxinim

@Maxinim Have you solved this problem?

lovelyelfpop avatar Mar 06 '18 01:03 lovelyelfpop

Hi @lovelyelfpop, I'm not sure yet. Currently I created a fork of this repository, and made a change to use unpooled byte buffers. But I had to work on something else in the meantime, so not sure it helped. Currently no OOM since I started to work on my project again (yesterday...), I'll wait and see.

In SocketIOServer.java, line 171 (or maybe 170, I think I added an import too), I replaced this :

bootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(config.getTcpReceiveBufferSize()));

by that :

bootstrap.childOption(ChannelOption.ALLOCATOR, new UnpooledByteBufAllocator(true));

Maxinim avatar Mar 09 '18 08:03 Maxinim

@lovelyelfpop I talked too fast... I just got an OOM right now. So my fix didn't work. Anyone has anymore input on this ?

Maxinim avatar Mar 09 '18 09:03 Maxinim

@lovelyelfpop I talked too fast... I just got an OOM right now. So my fix didn't work. Anyone has anymore input on this ?

Have you fixed this ? I've got this trouble too!

suood avatar Sep 27 '20 07:09 suood