At first I wanted to ask for a finalize method on the Statement class.
int sqlite3_finalize(sqlite3_stmt *pStmt);
https://sqlite.org/c3ref/finalize.html
But looking at the code I think this is already handled automatically? https://github.com/JoshuaWise/better-sqlite3/blob/18b957249b2891698231493f42e99a20ace5def9/src/objects/statement.lzz#L41-L45
I'm not familiar with the native side of Node at all. Do I interpret that correctly that the destructor handles that and is called when the garbage collector cleans up? So if I assign a new statement to an existing variable (and no other references exist), the old statement will automatically be finalized in SQLite? If this is correct then you can close the issue!
Yes, there's no finalize method in better-sqlite3 because memory is managed by the garbage collector, as you would expect from any regular JavaScript package. The garbage collector calls the destructors, and the destructors finalize the statement.
Also, if a database object is cleaned up by the garbage collector, it is automatically closed.
Thank you for the amazing work you are doing.
Most helpful comment
Yes, there's no
finalizemethod inbetter-sqlite3because memory is managed by the garbage collector, as you would expect from any regular JavaScript package. The garbage collector calls the destructors, and the destructors finalize the statement.Also, if a database object is cleaned up by the garbage collector, it is automatically closed.