-
Notifications
You must be signed in to change notification settings - Fork 592
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
TcpClient/Socket objects disposed but still exist in memory #263
Comments
We can certainly null the socket field in the Close method of |
We use EasyNetQ library and just call RabbitHutch.CreateBus and then Publish / Subscribe methods. App uses 6 RabbitAdvancedBus instances at the same time, serving 6 rpc-request and around 20-40 rpc-response queues. |
Why do you think that the Connection object has been closed? |
If the socket and TcpClientAdaptor have already been disposed why keep the Connection instance around? IIRC EasyNetQ doesn't use the AutorecoveringConnection so not sure what the scenario is where the socket has been disposed but the Connection is still somehow in use. |
Indeed, connection is closed (m_closed = true). But EasyNetQ really holds reference to Model object, which in turn holds reference to closed Connection. |
May be worth getting onto the EasyNetQ maintainers and ask them to clean up after connection close. |
May be, but it is good practice to break clearly known references to dead objects trees in own code. It protects from improper external use (as EasyNetQ does) and reduces memory footprint. |
We can do both ;)
|
Thank you! I will continue to investigate improper memory usage in EasyNetQ code. |
Memory dump of our running app shows something like this:
Both TcpClient and Socket objects have already been disposed, but still in memory referenced by TcpClientAdapter. TcpClientAdapter has private TcpClient / Socket field (depends of rabbitmq-dotnet-client version) which closed (disposed) in TcpClientAdapter.Close() method. We can consider this situation as memory leak with non-growing memory overhead.
It's annoying to have those broken and unused objects (with all inner object trees, e.g. byte arrays or ManualResetEvents) in memory and in profiler reports. These objects prevent from investigation real memory leaks.
Please, consider to break reference to TcpClient / Socket in TcpClientAdapter after Close() call.
Maybe, it's better to break reference a bit higher in call stack, e.g. SocketFrameHandler class.
The text was updated successfully, but these errors were encountered: