[Interest] SQLite database: avoid high memory usage?

coroberti coroberti at gmail.com
Mon Jan 24 11:09:28 CET 2022


On Mon, Jan 24, 2022 at 11:40 AM Hamish Moffatt via Interest
<interest at qt-project.org> wrote:
>
> On 24/1/22 19:40, Alexander Dyagilev wrote:
> > Hello,
> >
> > Let's suppose we have a database file of 16GB in size.
> >
> > We open it using this code:
> >
> > m_db = QSqlDatabase::addDatabase(
> >              "QSQLITE",
> >              dbConnectionName());
> > m_db.setConnectOptions("PRAGMA jounal_mode=WAL;");
> > m_db.setDatabaseName(m_dbPath);
> > m_db.open();
> >
> > After this, our process will use 16GB of memory (at least, under
> > Windows OS). I.e. the whole database file is loaded into the memory.
> >
> > Is there a way to avoid this?
>
>
> Did you mean to misspell journal_mode?
>
> Are you sure it's real memory usage and not just address space used by mmap?
>
>
> Hamish
>

Indeed. Doubts if on Windows it will be all really mapped:
https://docs.microsoft.com/en-us/windows/win32/memory/memory-limits-for-windows-releases

Besides that, to keep large areas mapped in RAM,
one may need to lock the pages in memory with their own limits.

Consider inspecting the sources of the SQL-db concerned.

Kind regards,
Robert


More information about the Interest mailing list