Hi,

I'm checking the memory usage of an application I've made. It makes numerous calls to read and write values to and from a database. I've observed the following:

* QSqlQuery::exec() uses some KB of RAM to execute a given query, but does not release the memory after it goes out of scope.

* QSqlDatabase:: open() & close() do not help free resources as the documentation suggest. If anything, close() causes resources (at least memory) to remain 'trapped' on the heap/stack.

For example, here is a typical segment of code I've been using to access my database.

Qt Code:
  1. QStringList values;
  2. db.open();
  3. QString strQuery = "SELECT DISTINCT " + field + " FROM " + table + str;
  4.  
  5. QSqlQuery query(db);
  6. query.prepare(strQuery);
  7.  
  8. if(query.exec() == true)
  9. {
  10. while(query.next())
  11. {
  12. values.push_back(query.value(0).toString());
  13. }
  14. }
  15.  
  16. db.close();
To copy to clipboard, switch view to plain text mode 


Having experimented with I find the code below 'traps' less memory:

Qt Code:
  1. QStringList values;
  2. QString strQuery = "SELECT DISTINCT " + field + " FROM " + table + str;
  3.  
  4. QSqlQuery query(strQuery, db);
  5.  
  6. while(query.next())
  7. {
  8. values.push_back(query.value(0).toString());
  9. }
To copy to clipboard, switch view to plain text mode 

However, a small amount of memory is still not released. Has anyone else experienced anything like this? Comments?