Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
Am I hitting artificial QSqlDatabase limits?

I have a function which has been working well for ages, which begins

QSqlDatabase
DBUtil :: basic_open (const QString & path)
{
    static int connection_num = 0;
    static const QString CONNECTION_NAME = "Connection%1";

    QSqlDatabase db = QSqlDatabase :: addDatabase (
        "QSQLITE",
        CONNECTION_NAME .arg (connection_num++));

    db .setDatabaseName (path);

    if (false == db .open ())
    {
         // error

I am using this to open and read from many small SQLite databases, each ~200k, and when opening the 1013th one it fails with

 out of memory Error opening database

The total application's memory load is ~200M, with gigabytes free on the machine.

It seems like I'm hitting a limit other than sheer memory. Each QSqlDatabase object goes out of loop scope before the next is created, these databases aren't all existing concurrently, and I can't see any connection limits mentioned in the documentation. So I'm confused.

lsof reports about 200 open file handles before this loop starts and about 1,200 when it finishes, so it looks like Qt is keeping the handles open after ~QSqlDatabase, but still, if that's the limit it seems a bit low.

Any idea what's going on? This is on up-to-date Ubuntu.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

First of all - QSqlDatabase is a singleton, so scope doesn't matter.

Try to close connection before opening new one.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!