How heavy is QObject really? [duplicate]

北慕城南 提交于 2019-11-27 03:14:38

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15763088/how-heavy-is-qobject-really

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!