Hi,
This is not a bug report or feature request but actually I'd like to ask for help debugging a possible memory leak.
In the following screenshot you can see that ~51% of the used heap is kept by WebSocketWorker and WebSocketImpl.

And here we see that actually WebSocketImpl#outQueue (with hashcode 0x7127e8b30) is the one keeping the memory.

Its size is 25320:

Debugging the code I've seen that outQueue is populated when I use org.java_websocket.WebSocket#send(java.lang.String) method. At that time there is a check whether the connection is still opened and WebsocketNotConnectedException is being thrown in case it is not. Then org.java_websocket.WebSocketImpl#write(java.nio.ByteBuffer) is called where there the buf is just put into outQueue.
Later in the run loop of org.java_websocket.server.WebSocketServer#run() the outQueue must be drained and actually sent to the client. In case of an error an IOException is thrown and org.java_websocket.server.WebSocketServer#onClose(WebSocket, int, String, boolean) callback is called.
One thing that I notice is that neither org.java_websocket.server.WebSocketServer#handleIOException() nor org.java_websocket.WebSocketImpl#closeConnection(int, java.lang.String, boolean) clear the contents of inQueue and outQueue. But I am not sure whether this is the reason for the huge out queues I have in the heap dump.
Do you have an idea what could be the problem and what I could do to debug more ?
I use version 1.3.8. I see that 1.3.9 is released and I will upgrade to it but I do not see anything that might fix it in the changelog.
For the heap analysis I use Eclipse Memory Analyzer (v 1.8.0).
Thank you!
Hi,
This is not a bug report or feature request but actually I'd like to ask for help debugging a possible memory leak.
In the following screenshot you can see that ~51% of the used heap is kept by WebSocketWorker and WebSocketImpl.
And here we see that actually

WebSocketImpl#outQueue(with hashcode0x7127e8b30) is the one keeping the memory.Its size is 25320:

Debugging the code I've seen that
outQueueis populated when I useorg.java_websocket.WebSocket#send(java.lang.String)method. At that time there is a check whether the connection is still opened andWebsocketNotConnectedExceptionis being thrown in case it is not. Thenorg.java_websocket.WebSocketImpl#write(java.nio.ByteBuffer)is called where there thebufis just put intooutQueue.Later in the run loop of
org.java_websocket.server.WebSocketServer#run()theoutQueuemust be drained and actually sent to the client. In case of an error an IOException is thrown andorg.java_websocket.server.WebSocketServer#onClose(WebSocket, int, String, boolean)callback is called.One thing that I notice is that neither
org.java_websocket.server.WebSocketServer#handleIOException()nororg.java_websocket.WebSocketImpl#closeConnection(int, java.lang.String, boolean)clear the contents ofinQueueandoutQueue. But I am not sure whether this is the reason for the huge out queues I have in the heap dump.Do you have an idea what could be the problem and what I could do to debug more ?
I use version 1.3.8. I see that 1.3.9 is released and I will upgrade to it but I do not see anything that might fix it in the changelog.
For the heap analysis I use Eclipse Memory Analyzer (v 1.8.0).
Thank you!