On 8/5/19, Simon Willison <swilli...@gmail.com> wrote: > > My concern is more queries that might use an enormous quantity of RAM or > starve the CPU. > > I'm using the Python standard library sqlite3 module,
(1) You could monitor SQLite memory usage in your progress callback and interrupt the running query if the memory usage goes over some threshold, perhaps. (2) There is also a patch (https://www.sqlite.org/src/info/b0ccef61a7f92d20) that adds a new "sqlite3_hard_heap_limit()" interface and PRAGMA. If you apply this patch, then you could set an upper bound on the amount of memory SQLite is allowed to use and it will return SQLITE_NOMEM if it ever goes over that limit. (3) You can also register your own memory-allocator at start time, and instrument your custom memory allocator to fail after using too much memory. (4) If you compile with -DSQLITE_ENABLE_MEMSYS5, then SQLite builds in its own optimal memory allocator that uses only memory from a single big allocation you provide it at start-time. So you give SQLite 30MB (or whatever you think is appropriate) to play with, and it uses that and only that memory, and never goes to malloc(). -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users