-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in WebSocketImpl.outQueue #773
Comments
Hello @martin-g, thank you for your bug report! Running everything with the profiler, I saw some left over references to The problem is in my eyes, that the WebSocketWorker is referencing an instance but will still keep it until a new WebSocketImpl instance is put into the queue and therefore gc cannot clean up everything. I attached a patched version. Could you please check if this solves the issue. If not I may need additional steps to repeat! Best regards, |
Thank you, @marci4 ! Could you please push your changes in a branch so I can see them ? |
@martin-g any news? |
I will take some heap dumps and take a look later today! |
Hi @marci4, Everything looks in today's heap dump! |
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
outQueue
is 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 andWebsocketNotConnectedException
is being thrown in case it is not. Thenorg.java_websocket.WebSocketImpl#write(java.nio.ByteBuffer)
is called where there thebuf
is just put intooutQueue
.Later in the run loop of
org.java_websocket.server.WebSocketServer#run()
theoutQueue
must 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 ofinQueue
andoutQueue
. 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!
The text was updated successfully, but these errors were encountered: