-
Notifications
You must be signed in to change notification settings - Fork 133
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
InfluxDB::Client is never garbage collected #259
Comments
For some evidence: require 'influxdb'
require 'memory_profiler'
MemoryProfiler.report { InfluxDB::Client.new }.pretty_print =>
|
Thanks for reporting this issue. Have you looked into it further? I assume it is a hot issue and lies on the critical path. |
It wasn't that hot, but if the client is instantiated again and again, that did contribute to unbounded memory growth. We ultimately went with either with a pool or with a global client instance. I can't remember which of these two, sorry. |
Hot or not, it doesn't matter if it doesn't occur now. Thanks. |
It does occur. Be careful not to instantiate a new instance of InfluxDb::Client in your web request handlers. |
I'm guessing that happens (or doesn't happen) because of the
at_exit
block inside its constructor.I think it should either be reworked to use just one global
at_exit
somewhere on the module level, or the docs should clarify somewhere that one should create one client instance globally. That is, to avoid creating instances dynamically per request (in a web app).I also haven't managed to find any info as to whether the client is thread-safe, or we should use it through a connection pool.
The text was updated successfully, but these errors were encountered: