Though SQLite supports very large databases, including in-memory databases, the maximum amount of memory that SQLite will itself allocate in a single go is 2GiB. If you want a deserialized database that is larger than that, you will need to allocate the memory yourself (using some mechanism other than [sqlite3_malloc64()](https://www.sqlite.org/c3ref/free.html) which will fail for such large allocations) and pass the memory directly to [sqlite3_deserialize()](https://www.sqlite.org/c3ref/deserialize.html). You won't be able to use the SQLITE_DESERIALIZE_FREEONCLOSE or SQLITE_DESERIALIZE_RESIZEABLE flags.