Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Measure Heap Memory allocated for QList?
Forum Updated to NodeBB v4.3 + New Features

Measure Heap Memory allocated for QList?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.2k Views 1 Watching
  • 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.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    I have a QTableWidget in my Main Window. I have created QTableWidgetItem from heap & set them for each cell.
    Due to some reasons I am storing the contents of the item of each cell in individual QString objects which are also created of the heap.
    I am maintaining the associativity by using QList for each row & another QList to store references of all such QList's. Thus it is something like this:

    @QList <QList <QString *> *> *mycells;@

    Now I can access the QString for each cell by:

    @for(int i = 0; i < mycells->size(); i++)
    {
    QList <QString *> *rows = (*mycells)[i];
    for(int j = 0; j < rows->size(); j++)
    {
    QString *mystr = (*rows)[j];
    }
    }@

    If anybody can tell whether there is anything wrong in my approach, then please let me know.

    OK, so now the problem is that when I increase the rows from 0 & columns from 0 for the table to, rows = 1000 & columns = 1000 i.e. there are 1000000 cells then my application is showing increase in memory by ~200MB in the task manager.
    Now I want to test how much of that is due to @QList mycells@.
    How do I do that?
    Ideally how much memory would be required for a QTableWidget including all the QTableWidgetItem's & Horizontal & Vertical Headers of size 1000x1000?

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      we had such a questions a few days ago "here":http://qt-project.org/forums/viewthread/27259/.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        Hi there.
        What you ask is almost impossible te answer! A QList is as big as the members in it, but you guessed it already. The QString will automatic allocate more memory when needed if more text needs te be stored in the cell. So, no, there is not a complete valid answer for your question.
        About the first part, it seems that you are manually creating a sort of Model/View setup. The model/View topology was created to avoid what you are doing ;-)
        Maybe read the tutorial:
        "Model/View link":http://qt-project.org/doc/qt-4.8/model-view-programming.html

        At first the QTableWidget will do just fine, but when getting to know the MVC it is really easy to use to support massive amounts of data without difficult update/check routines etc.

        Hope this helps a bit

        Greetz, Jeroen

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved