-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 when not using connection pooling #1139
Comments
You are leaking memory in Basically, you are using the API wrong. You should be storing the |
Hi Jeremy, Thanks for a prompt reply. I feel like a true fool now... 😄 You're absolutely right - I checked and if I pass a block to the I looked at the opening database page in the documentation now, and it doesn't seem to be very clear that this happens. It says "it is recommended that you store the database object in a constant named DB", but perhaps we should make it more clear that there are great dangers with not storing it in a constant. (obviously, we missed this) Anyway, our specific use case is within an application server and we can change this code fairly simply to use the block form instead. But removing it from Thanks a lot for your help. |
I agree, this could be better documented. It is documented, but it probably should be made more prominent in the guide. Could you please send a documentation pull request?
|
Thanks a lot for the help, will try that. The use case here is definitely multi-threaded (a Rack-based web server), so it was great to get a proper example that works in that use case as well. |
This is a basically a followup to jeremyevans#1139, trying to help other people avoid making the same mistake that I have been doing. 😄
Hi,
We've just concluded a debugging session for one of our apps, which has been running in production for a few years. The application server (using JRuby 1.7) tends to run out of memory over time, so the customer has scheduled reboots of the machine in place, as a workaround.
Today, we debugged this a bit more and found out the following very interesting facts:
Here are the results when using unpooled connections (the full script below):
...and when using the
connect_pooled
method instead:Running Sequel 4.31.0, JRuby 1.7.22, Java 1.7.0_80.
I certainly know that connection pooling should be used in production-level systems. 😄 And we will "solve" this by enabling it in this specific use case. Still, I think it's a bad sign that "something" is leaking memory in this way when not having it enabled. Any ideas on how to proceed with trying to pinpoint this?
The text was updated successfully, but these errors were encountered: