Question

I recently posted a question about the overhead of QObject in typical usage scenarios, but unfortunately the question got closed as a duplicate of another question that didn't technically answer the question.

What is worse, the hasty "Samaritans" who politely rushed to close my question interrupted the answer I was just finishing typing after running a few tests. Since I can no longer post my findings in my original question, I'll post it here so it is available to others who might need that information.

Was it helpful?

Solution

A lot of people have hinted at QObject being heavy, but without any clarity on how heavy is it exactly. So I did some measurements, not very accurate, all values are approximate.

  • unused QObject ~160 bytes
  • single auto connection w/o arguments ~235 bytes
  • 2 auto connections w/o arguments ~315 bytes
  • 3 auto connections, 1 with 3 arguments ~400 bytes
  • 2 auto connections, 1 queued with 3 arguments ~432 bytes

Those numbers should take into account I am using a 64 bit Qt build.

So, in conclusion, the overhead of QObject is quite significant indeed. Nothing to sneeze at or overuse.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top