Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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.

    Best



  • Answer is:

    query.setForwardOnly( true );
    

  • Lifetime Qt Champion

    Hi,

    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