[Interest] Evaluating the results of QSqlQuery across different threads resulting in memory leaks

Thiago Macieira thiago.macieira at intel.com
Mon Dec 11 23:10:21 CET 2017


On Monday, 11 December 2017 13:39:39 PST mike neuhaus wrote:
> However it might problematic if the results are not cached after until I
> actually retrieve values from the QSqlQuery. Because the retrieval of
> values will always happen on a different thread (we copied the QSqlQuery
> object created in the serializer thread to thread where we created the
> SqlReply). Can someone confirm that the way I'm currently doing this is
> indeed not supported by QT and/or the underlying SQLite driver?

That is correct: QSqlQuery will contact the database to obtain more records.

Don't access the QSqlQuery object from multiple threads. Have your serialiser 
thread decode and extract the necessary information, storing it in plain 
types.

Or open multiple QSqlDatabase connections.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list