You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unfortunately, this is insufficient to prevent memory leaks -- I've added some tests that fail when rake test:valgrind is run (on a Linux system) to demonstrate the problem.
I think this is happening because we can't guarantee that the statement will be finalized before the database is closed. See Closing A Database Connection for more information on what happens when the order is reversed.
I think this is happening because we can't guarantee that the statement will be finalized before the database is closed. See Closing A Database Connection for more information on wha
I suspect you're not wrong. But I think we might (possibly maybe) be able to do a GC trick that keeps the connection open 1 GC cycle past the statement. AFAIU, the only time we wouldn't be able to guarantee this order is in the case a database object and a statement object are collected at the same time. I think there's a way we can force the connection to stay alive for one more GC. IIRC we do this in CRuby for classes, but idk if the C APIs are public.
prevents memory leak when `close` is not called before a ResultSet is
garbage collected
also add coverage for statement resource cleanup
Co-authored-by: Mike Dalessio <mike.dalessio@gmail.com>
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevents memory leak in the case that
close
is not called before aResultSet
is garbage collected.close
setsc->st
toNULL
immediately after callingsqlite3_finalize
itself, so there is no double-free risk introduced with this change.