File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -16,20 +16,15 @@ please look there for additional information.
16
16
17
17
All statements keep pointers back to their respective database connections.
18
18
The ` @connection ` instance variable on the ` Statement ` handle keeps the database
19
- connection alive. Memory allocated for a statement handler will be freed in
20
- two cases:
19
+ connection alive.
21
20
22
- 1 . ` #close ` is called on the statement
23
- 2 . The ` SQLite3::Database ` object gets garbage collected
24
-
25
- We can't free the memory for the statement in the garbage collection function
26
- for the statement handler. The reason is because there exists a race
27
- condition. We cannot guarantee the order in which objects will be garbage
28
- collected. So, it is possible that a connection and a statement are up for
29
- garbage collection. If the database connection were to be free'd before the
30
- statement, then boom. Instead we'll be conservative and free unclosed
31
- statements when the connection is terminated.
21
+ We use ` sqlite3_close_v2 ` in ` Database#close ` since v2.1.0 which defers _ actually_ closing the
22
+ connection and freeing the underlying memory until all open statments are closed; though the
23
+ ` Database ` object will immediately behave as though it's been fully closed. If a Database is not
24
+ explicitly closed, it will be closed when it is GCed.
32
25
26
+ ` Statement#close ` finalizes the underlying statement. If a Statement is not explicitly closed, it
27
+ will be closed/finalized when it is GCed.
33
28
34
29
35
30
## Building gems
You can’t perform that action at this time.
0 commit comments