jeudi 15 janvier 2015

SQLite Memory Consumption - Why so high?

I have a c++ application (Winx64) that I am prototyping and I am noticing that the memory consumption when using SQLite is 6GB in size when the database itself is 200MB on disk. If I remove all statements which perform database functions, my application never gets above 700MB (which includes the data to be loaded into SQL from internal buffers).


Here is what I am doing:



  • Create the database

  • Create 10 tables

  • Load tables with 1.318 million rows

  • Raw data size is 578MB


I have journaling turned off. Synchronization is turned off.


I am using prepared SQL statements for the inserts. Batch size for each commit is 1000 records After each commit, I manually run a PRAGMA shrink_memory and VACUUM


sqlite3_memory_highwater shows only 1.1GB and sqlite3_memory_used shows 700mb.


At the end of the program I run _CrtDumpMemoryLeaks(); and it shows no memory leaks (other than my class initializer strings).


Why is SQLite using 6GB of RAM (according to the performance monitor for both workingset and private bytes)?


I even tried something along these lines just to make sure it wasn't held up in my constructor:



int main(void)
{
dbClass *db = new dbClass("Sample.db");
DoWork();
delete db;
_CrtDumpMemoryLeaks();
cin.get();
}


And still shows 5GB allocated.


What am I missing?


Aucun commentaire:

Enregistrer un commentaire