Results 1 to 4 of 4

Thread: How to decrease the model size in memory?

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default How to decrease the model size in memory?

    Hello every body,
    I am using QAbstractTableModel to represent more than 4000,000 record, when I scroll down the view to the end the application size is increased in the memory from 50 MB to 111 MB.
    Qt Code:
    1. QVariant SearchModel::data(const QModelIndex &index, int role) const
    2. {
    3. if(!index.isValid())
    4. return QVariant();
    5. switch(role)
    6. {
    7. case Qt::DisplayRole:
    8. {
    9. switch(index.column())
    10. {
    11. case 0: // serial
    12. {
    13. return index.row()+1;
    14. }
    15. break;
    16. case 1: // text
    17. {
    18. return m_pSearchEngine->getHighlightedText(index.row(), false);
    19. }
    20. break;
    21. case 2: // book name
    22. {
    23. return m_pSearchEngine->getBookName(index.row());
    24. }
    25. break;
    26. case 3:
    27. {
    28. return m_pSearchEngine->getTitle(index.row());
    29. }
    30. break;
    31. case 4: // part no
    32. return m_pSearchEngine->getPartNo(index.row());
    33. break;
    34. case 5: // page no
    35. return m_pSearchEngine->getPageNo(index.row());
    36. break;
    37. }
    38. }
    39. break;
    40. }
    41. return QVariant();
    42. }
    To copy to clipboard, switch view to plain text mode 
    I examined the functions I used it just return strings.
    How can I decrease the amount of memory that the model take?
    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to decrease the model size in memory?

    If you have 4M rows then if your memory footprint increases by 60M then it means on average each row cost you 15 bytes. I'd say it's not that bad. To reduce the footprint you can reduce the number of rows.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to decrease the model size in memory?

    This means that the data is stored in the view so that whenever the rows are increased the size is increased.

    but I can not reduce the search results , but i can make an idea just like google search by displaying 100 row each time.

    what is the widget suitable for this?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to decrease the model size in memory?

    You can use any of the views available. Just limit your model. If you're worried about memory footprint, make sure you are not using QSortFilterProxyModel anywhere as it keeps an internal map of nodes in your base model.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. how to fing the stack memory size ?
    By john_god in forum General Programming
    Replies: 2
    Last Post: 17th June 2009, 01:30
  2. Decrease the size of Application in Mac?
    By vishal.chauhan in forum Installation and Deployment
    Replies: 2
    Last Post: 26th March 2009, 10:54
  3. How to increase/decrease brightness/sharpness
    By rishiraj in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 06:25
  4. need to decrease the library size
    By rohan_m_e in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th November 2008, 04:38
  5. Qt Memory size problem ?
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 29th September 2008, 15:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.