PDA

View Full Version : Maximum size of QStandardItemModel



jasonhxs
9th June 2015, 08:48
Hi,

I suffer a crash issue when use QStandardItemModel with huge row*column

#10 0x00002aaaabb007a8 in QVector<QStandardItem*>::realloc(int, int) ()
...

the row is 30000, column is 29656.

Do you have idea about the maximum size that we should limit in QStandardItemModel, thanks.

wysota
9th June 2015, 10:07
30000 * 29656 = 0.88E9 items. QStandardItem has size of 16 bytes in Qt5. Assuming no items keep any data (they are empty) the model already occupies almost 16 gigabytes of memory. Do you have that much in your machine? Once you add data to each item (setting things like text, color, font, etc.) the size of each item will grow. Do you have enough memory to contain that much data?

To answer your question:


Do you have idea about the maximum size that we should limit in QStandardItemModel, thanks.
There is no set limit on the size of the model as the model may have practically infinite depth.

d_stranz
9th June 2015, 23:31
the row is 30000, column is 29656.

This sounds like a design problem to me. Do you really need to keep almost 900 million things in a model (and in memory) at the same time? Are all of them going to contain something, or will most of them be empty?