Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QSql query.next keep memory fat

    General and Desktop
    2
    3
    52
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      RahibeMeryem last edited by

      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

      1 Reply Last reply Reply Quote 0
      • R
        RahibeMeryem last edited by

        Answer is:

        query.setForwardOnly( true );
        
        1 Reply Last reply Reply Quote 1
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 1
          • First post
            Last post