What is the size of a QList::Data, RenderObject?

What is the size of a QList::Data, RenderObject?

We tend to write classes without really caring about what the compile will do to create the binary file. When looking into performance and specially memory usage and you create certain objects thousands of times it becomes interesting of how much memory one is wasting for padding/no good reason.

The Linux kernel hackers wrote a tool called pahole that will analyze the DWARF2 symbols and then spit out friendly messages like the one below.


struct Data {
class QBasicAtomicInt ref; /* 0 4 */
int alloc; /* 4 4 */
int begin; /* 8 4 */
int end; /* 12 4 */
uint sharable:1; /* 16:31 4 */

/* XXX 31 bits hole, try to pack */

void * array[1]; /* 20 4 */

/* size: 24, cachelines: 1, members: 6 */
/* bit holes: 1, sum bit holes: 31 bits */
/* last cacheline: 24 bytes */

In this case QList::Data could have used at least three bytes less memory and changing the definition of sharable and array would have removed a whole in the struct. Maybe that is something for Qt5 to keep in mind.

The research question. Can QtWebKit memory usage be reduced by shrinking some of the Qt structs without losing functionality?

Comments are closed.