SQLite Forum

Test SQLITE_NOMEM result code on Linux (Memory : 8Gb)
Login
You can register your own memory allocator using the
[sqlite3_config(SQLITE_CONFIG_MALLOC, ...)[1] interface.  This is what the
various SQLite test harnesses do.  Normally calls to the custom malloc fall
through into system malloc, but it is possible to inject faults.  There
is an example of doing this in the [CLI source code][2].

You might also set the [PRAGMA hard_heap_limit][3] to some small value
in one connection, and then open a separate connection.  The hard_heap_limit
applies to the entire process, not to individual connections.

[1]: https://www.sqlite.org/c3ref/c_config_covering_index_scan.html
[2]: src:/info/9df263dc09496?ln=524-530
[3]: https://sqlite.org/pragma.html#pragma_hard_heap_limit