How heavy is QObject really?(QObject 到底有多重?)
问题描述
我最近发布了一个关于 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.
推荐答案
很多人都暗示 QObject 很重,但并不清楚它到底有多重.所以我做了一些测量,不是很准确,所有数值都是近似值.
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.
- 未使用的 QObject ~160 字节
- 没有参数的单个自动连接 ~235 字节
- 2 个不带参数的自动连接 ~315 字节
- 3 个自动连接,1 个带有 3 个参数 ~400 字节
- 2 个自动连接,1 个排队,有 3 个参数 ~432 字节
这些数字应该考虑到我使用的是 64 位 Qt 版本.
Those numbers should take into account I am using a 64 bit Qt build.
所以,总而言之,QObject 的开销确实相当大.没有什么可以打喷嚏或过度使用.
So, in conclusion, the overhead of QObject is quite significant indeed. Nothing to sneeze at or overuse.
这篇关于QObject 到底有多重?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:QObject 到底有多重?
基础教程推荐
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
