[Qt-interest] QSqlDatabase issue on AIX 6.1
Philipp
qt at phiworld.de
Mon Dec 20 16:10:40 CET 2010
Hi all,
I have a memory leak problem running a Qt4.5.3, GCC compiled application
on AIX 6.1 using the QSqlDatabase and QSqlQuery classes together with
the OCI driver (quering an Oracle 10 database):
Everything works fine up to that point that when I do some kind of
"complex" INSERT, the memory usage increases by approx. 28 KB.
In operational use, this sums up to around 200MB a day.
Maybe someone has an idea? Here is my approach:
In general, I use a single object of a class that holds a member of type
QSqlDatabase: m_database
constructor of MyClass:
m_database = QSqlDatabase::addDatabase("QOCI",
DATABASE_CONNECTION_NAME);
m_database.setHostName("127.0.0.1");
m_database.setPort("1521");
m_database.setDatabaseName(...);
m_database.setUserName(...);
m_database.setPassword(...);
bool ok = m_database.open();
if (!ok)
{
...
}
I am doing periodically some INSERTs like this:
void MyClass::insertDataToDatabase(...)
{
m_database.transaction();
QSqlQuery query(m_database);
qlonglong maxIntervalId = 0;
query.exec("SELECT MAX(ID) FROM table_1");
while (query.next())
{
maxId = query.value(0).toLongLong();
}
while (...)
{
insertIntoTable1(query, maxId, ...);
while (...)
{
while (...)
{
insertIntoTable2(query, ...);
}
}
}
m_database.commit();
}
with the methods "insertIntoTable1" and "insertIntoTable2" taking a
non-const reference of "query" as parameter:
void MyClass::insertIntoTable1(QSqlQuery& query, qlonglong maxId, ...)
{
query.prepare("INSERT INTO table_1...");
query.bindValue(0, maxId);
query.bindValue(1,...);
...
bool ok = query.exec();
if (!ok)
{
...
}
}
I already tried replacing the member variable m_database by a
QSqlDatabase::database(...) call without success.
Any tips and hints are welcome!
Thank you!
Philipp
More information about the Qt-interest-old
mailing list