Skip to content
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

severe memory leak in new version #67

Closed
smasherprog opened this issue Mar 31, 2020 · 6 comments · Fixed by #68
Closed

severe memory leak in new version #67

smasherprog opened this issue Mar 31, 2020 · 6 comments · Fixed by #68
Assignees
Labels

Comments

@smasherprog
Copy link

We upgraded to the latest version 1.3.0 and have found a serious memory leak issue.

I have attached a screenshot of a memory dump of our website which was affected by this
Capture

This is what is inside of the networkchange handler
Capture1

We use the latest version of MongoDB.Driver 2.10.2 in our application which uses this library.

As you can see from the memory dumps, it looks like the dnscache is filling up with too many entries. This causes our application to slowly become unresponsive. My guess is that looking through the 100k entries in the dnscache is a slow.

I am unsure why this occurs or how to reproduce it as it seemed to occur randomly. Let me know of anything I can do to help as we are now stuck using 1.2.0 hoping that it doesn't break our site (we have been getting bit by this #55) and 1.3.0 which causes random site unresponsiveness.

@MichaCo MichaCo self-assigned this Mar 31, 2020
@MichaCo MichaCo added the bug label Mar 31, 2020
@MichaCo
Copy link
Owner

MichaCo commented Mar 31, 2020

I shouldn't add new features while sick it seems -.-
Didn't thought about the bad behavior of events which basically keep the reference alive forever.

The memory footprint should be zero after creating an instance of LookupClient and not keeping any references, so this is clearly a bug which I will fix.

I'd have to make the LookupClient IDisposable to make it unsubscribe properly though, and I don't want to do that... therefore I'll remove that feature.

Thanks for figuring that out and letting me know! 👍

That being said, that's an absurd amount of instances of LookupClient.
Does that mean the MogoDB.Driver creates a new instance every time you call it or something?
That would be pretty unfortunate because there is some performance overhead instantiating the client with auto-nameserver discovery (it has to query network interfaces and such which will take a couple milliseconds)..
And caching is basically disabled if the instance isn't kept / reused.

@MichaCo
Copy link
Owner

MichaCo commented Mar 31, 2020

Should be fixed in https://github.com/MichaCo/DnsClient.NET/releases/tag/1.3.1 which was just pushed to Nuget.

Let me know if you still see any issues or if it works.

@smasherprog
Copy link
Author

Awesome we will take a look and see if this fixes the issue. Thanks for the quick response!

@DmitryLukyanov
Copy link

Does that mean the MogoDB.Driver creates a new instance every time you call it or something?

yep, we do it each time when we need to resolve a connection string. This is a ticket to solve it: https://jira.mongodb.org/browse/CSHARP-3038

@smasherprog , please let us know whether updating to a new package version solved your issue.

@smasherprog
Copy link
Author

The new version did fix our memory and slowness issue. We are running it on our production environment and its working!
The Mongo driver should up its version requirement for sure!

@MichaCo
Copy link
Owner

MichaCo commented Apr 2, 2020

Thanks @smasherprog for the confirmation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants