SQLite Forum

Understanding memory allocation behavior of SQLite
Login
SQLite's in memory db uses the same page layout that a disk based db would, it just never writes to the disk, thus if your 77M inserts are done separately, or even in batches but they involve wildly spaced primary keys then each row will probably have to allocate a full page, thus 4KB per inserted row, Multiply that by 77M and you get 300+ GB of allocated memory, now index inserts will also require page sized memory allocations, so you should double that to 600+ GB, roughly what you are seeing.