QSqlQueryModel and memory consumption
Hello,
if i create a new insatance of a QSqlQueryModel (based on sqlite database) the amount of memory is not completely freed when deleting the object.
Code:
.
..
model->setQuery(query);
while(model->canFetchMore())
model->fetchMore();
..
delete model;
What is the correct way to do this?
Re: QSqlQueryModel and memory consumption
Delete the query as well. Sqlite is a caching driver, so that iterating over the dataset, will cache the values, allocating memory to do so. So, the memory you're seeing "not freed" is actually memory coming from the query object.
Re: QSqlQueryModel and memory consumption
Ho can i achieve that?
Tthere is no function to do that.
Re: QSqlQueryModel and memory consumption
Try QSqlQuery::clear();
I had a big memory load on the mysql-server side, because I didn't clear queries soon enough. I use QtScript to handle the queries (lots of them) and they are not deleted until the garbage collector picks them up, which is too late for me, so I had to use clear manually. Maybe it helps you, too.
Johannes