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

Using a single connection for a server will eat up Postgres memory #103

Open
vlidholt opened this issue Aug 14, 2019 · 3 comments
Open

Using a single connection for a server will eat up Postgres memory #103

vlidholt opened this issue Aug 14, 2019 · 3 comments

Comments

@vlidholt
Copy link

I initially used a single database connection to make all my (very small) queries. This will cause the database memory to slowly decrease until the database crashes.

I solved it by creating a new connection for each session in my server, but this seem to be a serious issue where the connection seem to cause the database to allocate memory which isn't returned until the connection is closed.

@isoos
Copy link
Collaborator

isoos commented Aug 14, 2019

Interesting observation. I've implemented a connection pool that would re-connect after a certain amount of use, but I thought that issue is some memory buildup on the Dart side, and not on the Postgresql side (never checked it though). Do you have a scenario where you can replicate this reliably? (e.g. running a Postgresql in docker and then doing the queries as a loop)

@itsjoeconway
Copy link
Contributor

Is it due to statement reuse for queries being on by default? The statement is stored in the database server for each query string, per connection. You can disable reuse with a boolean flag to your execution method if you are generating dynamic queries often.

@vlidholt
Copy link
Author

@joeconwaystk this sounds likely, thanks for pointing it out!

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

No branches or pull requests

3 participants