[sqlite] sqlite3_close() necessary?

7 views
Skip to first unread message

Bill McCormick

unread,
Jan 17, 2012, 11:51:10 AM1/17/12
to General Discussion of SQLite Database
What happens if my application fails to call sqlite3_close() before it
exits? Does it leave the db in some unknown state or open to corruption?

If I have a daemon type program, will I need to catch signals that try
to close/kill the program and call sqlite3_close() before exiting?

Thanks!!
_______________________________________________
sqlite-users mailing list
sqlite...@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Richard Hipp

unread,
Jan 17, 2012, 11:56:06 AM1/17/12
to General Discussion of SQLite Database
On Tue, Jan 17, 2012 at 11:51 AM, Bill McCormick <wpmcc...@gmail.com>wrote:

> What happens if my application fails to call sqlite3_close() before it
> exits? Does it leave the db in some unknown state or open to corruption?
>
> If I have a daemon type program, will I need to catch signals that try to
> close/kill the program and call sqlite3_close() before exiting?
>

Failure to call sqlite3_close() results in memory and file-descriptor leaks
if your process keeps running. But as those resources are cleaned up
automatically when the process exits, failure to call sqlite3_close() prior
to exit is harmless.

If you are using WAL mode, failure to call sqlite3_close() might leave -wal
and -shm lingering on your disk. But the next process to open the database
file will clean them up automatically, so no harm done.

>
> Thanks!!
> ______________________________**_________________
> sqlite-users mailing list
> sqlite...@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
>

--
D. Richard Hipp
d...@sqlite.org

Reply all
Reply to author
Forward
0 new messages