Qt World Summit: Submit your Presentation

QSql query.next keep memory fat

  • Hi;

    I want to take sqlite db to Eigen::Matrix from json. So I am doing:

    query.prepare("SELECT * FROM CSIJson ");

    while(query.next()) . {

    do stuff//

    Until this loop is finished memeory is getting bigger... it looks query keeping in the memory

    When here its released..

    How can I only keep current row from sqlite and not keep all ? Its makes memory very big until exiting loop.


  • Answer is:

    query.setForwardOnly( true );

  • Lifetime Qt Champion


    Does that table contain more that one column ?
    If so are you processing them all ?
    If not, then you should make a more precise query so that you only load the data you are going to use.

Log in to reply