问题描述
我最近发表了一个关于QObject在典型使用情况下的开销的问题,但不幸的是,问题已经关闭,因为另一个问题的技术上没有回答这个问题。
$ b $更糟糕的是,匆忙的撒玛利亚人礼貌地匆忙关闭我的问题,打断了我刚刚在完成几个测试后输入的答案。由于我无法在我的原始问题中发布我的发现,我会在这里发布,以便其他人谁可能需要这些信息。
很多人暗示QObject很重,但是没有任何清晰的确切的重。
- 未使用的QObject〜160字节
- 单个自动连接w / o参数〜235个字节
- 2个自动连接,参数大小为315个字节
- 3个自动连接3个参数〜400个字节
- 2个自动连接,1个排队,3个参数〜432个字节
这些数字应该考虑到我使用一个64位的Qt构建。
因此,总之,QObject的开销是相当重要的。没有任何东西可以打喷嚏或过度使用。
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.
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.
这篇关于QObject真的有多重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!