logoalt Hacker News

Leherennlast Saturday at 3:23 PM4 repliesview on HN

A bit off topic, but there seems to be quite a few SQLite experts here.

We're having troubles with memory usage when using SQLite in-memory DBs with "a lot" of inserts and deletes. Like maybe inserting up to a 100k rows in 5 minutes, deleting them all after 5 minutes, and doing this for days on end. We see memory usage slowly creeping up over hours/days when doing that.

Any settings that would help with that? It's particularly bad on macOS, we've had instances where we reached 1GB of memory usage according to Activity Monitor after a week or so.


Replies

asa400last Saturday at 3:25 PM

Are you running vacuums at all? auto_vacuum enabled at all?

https://sqlite.org/lang_vacuum.html

show 1 reply
kachapopopowlast Saturday at 3:26 PM

sounds like normal behavior of adjusting buffers to better fit the usecase, not sure if it applies to sqlite or if sqlite even implements dynamic buffers.

pstuartlast Saturday at 5:22 PM

If you're deleting all rows you can also just drop the table and recreate it.