mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.83k stars 1.66k forks source link

ByteBuf.release() was not called before it's garbage-collected record while run HttpTransportTest #1002

Open bwzhang2011 opened 2 months ago

bwzhang2011 commented 2 months ago

when I run HttpTransportTest and just made simple modification to the method of testMultipleMessages() :

@Test public void testMultipleMessages() throws URISyntaxException, IOException, InterruptedException { server.addEventListener("hello", String.class, (client, data, ackSender) -> ackSender.sendAckData(data)); final String sessionId = connectForSessionId(null); final ArrayList events = new ArrayList<>(); events.add("420[\"hello\", \"world\"]"); events.add("421[\"hello\", \"socketio\"]"); events.add("422[\"hello\", \"socketio\"]"); String[] responses = null; for(int i = 0 ; i < 200; i ++) { postMessage(sessionId, events.stream().collect(Collectors.joining(packetSeparator))); responses = pollForListOfResponses(sessionId); }

Assert.assertEquals(responses.length, 3);

}

I just hope to run some number of cycles as above to do simple performance test. but I got some memory-leak record with the attachment which I doubt that socketio whether or not has solved the bytebuf release problem and wonder those could lead to actual memory leak while in real production env. socketio_memory_lead.txt

  1. I'm not sure the number of cyles should match the way to induce what happend to the memory leak
  2. You can set the env jvm parameter: -Dio.netty.leakDetectionLevel=paranoid to locate where the memoy leak
  3. The record of the memory leak mainly points to the packet.decode method like the use case for packetBuf = frame.copy(frame.readerIndex(), separatorPos)

so I need your help to point out whether I did the right way to do some simple performance test and whether PacketDecoder exists the memory leak pitfall.