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

Explicit GC.gc() needed for SQLite.DB to become really out of scope. #285

Open
MarieJC opened this issue Feb 28, 2022 · 2 comments
Open

Comments

@MarieJC
Copy link

MarieJC commented Feb 28, 2022

Otherwise at the end of program execution sqlite database remains in use by Julia REPL.
And according to the doc: "The SQLite.DB will be automatically closed/shutdown when it goes out of scope (i.e. the end of the Julia session, end of a function call wherein it was created, etc" - turns out not true!
Link to JuliaLang discussion of the problem:
https://discourse.julialang.org/t/sqlite-database-remains-in-use-by-julia-repl/77194

@quinnj
Copy link
Member

quinnj commented Apr 14, 2022

Hi @MarieJC, thanks for opening an issue! Yeah, this is somewhat a general Julia "destructor" problem as we're relying on the finalizer functionality in Julia, which allows you to register a function that runs when an object is garbage collected. But the problem is, as you noted, it's not well-defined when objects actually get garbage-collected!

Do note that you can always call close(db) or more generally DBInterface.close!(db) to force a database connection to be closed, which we should probably highlight in the docs as the proper way to manage the lifetime resource of your sqlite database connection.

@MarieJC
Copy link
Author

MarieJC commented Apr 14, 2022

Thank you for your response! Yes, DBInterface.close!(db) works. But in my particular exercise the code operating on a db isspread between diff functions - so it is tricky to close the db at the very end. This is not a priority though!!! We were just testing out similar functionality in several languages, including Julia.

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

2 participants