Better-sqlite3: Feature/clarification: Statement#finalize

Created on 28 Feb 2020  路  2Comments  路  Source: JoshuaWise/better-sqlite3

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!

question

Most helpful comment

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.

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonataswalker picture jonataswalker  路  5Comments

faac-spazio-italia picture faac-spazio-italia  路  5Comments

ccpwcn picture ccpwcn  路  4Comments

imtbl picture imtbl  路  6Comments

DrDonkeyPunch picture DrDonkeyPunch  路  5Comments