6

I was curious how big QObject actually is, including the typical private data each instance creates dynamically. I couldn't get a sizeof for those, because of the way they are implemented.

EDIT: NOTE that I am asking about the size of a typical usage scenario for a QObject, I am not asking "how to get the size" which is what that other question is about, I am asking people who KNOW the approximate size, since obviously the language itself provides no means of reporting that.

dtech
  • 47,916
  • 17
  • 112
  • 190
  • Try valgrind perhaps? –  Apr 02 '13 at 10:32
  • @H2CO3 - I can't run it on my system – dtech Apr 02 '13 at 10:32
  • @Jueecy - the linked question contains no answer, I already went through it – dtech Apr 02 '13 at 10:35
  • @ddriver, the most upvoted answer says "There is no way of doing this in Standard C++" and explains why it is useless to do that anyway. It Seems and answer to me. Also there are four answers with score of 2 or more. – Shoe Apr 02 '13 at 10:37
  • 1
    @Jueecy it is not "an answer" just because it is labeled "answer" - it has to actually answer the question. It is not useless to know it for me, nor is calculating the size from an array of UNUSED QObject instances. – dtech Apr 02 '13 at 10:40
  • If you want to manually dig into it, see `qobject*.*` at http://qt.gitorious.org/qt/qt/trees/4.8/src/corelib/kernel – hyde Apr 02 '13 at 10:40
  • 1
    @ddriver, I never said it was an answer only because it was listed under "answers", I said that it is an answer to your question, because it actually does answer your question. Just because it's not what you were expecting for doesn't mean it's not answer. The answer is pretty clear: it's not possible. Period. – Shoe Apr 02 '13 at 10:42
  • @Jueecy check my question again, I made a clarification. I am well aware it is not possible, but then again I am asking something quite different. The question is "How big is QObject" so you see "it's impossible" doesn't really fit to be an answer. – dtech Apr 02 '13 at 10:44
  • @ddriver, to answer your edit: [read this answer](http://stackoverflow.com/a/1277494/493122) which gives you a code snippet to calculate that approximation. (One of the four answers of the duplicated question). – Shoe Apr 02 '13 at 10:47
  • @Jueecy re-read my second comment again – dtech Apr 02 '13 at 10:49
  • @ddriver If you have a system which can not run valgrind, you should probably install a VM and download a pre-made Linux virtual disk (I've been using VirtualBox+Lubuntu on Win7 lately, been fine). Results might not be accurate to the byte between systems, but should satisfy your curiosity. – hyde Apr 02 '13 at 10:54
  • 4
    If someone else cares about the actual answer and not just about closing unanswered questions: http://stackoverflow.com/questions/15763088/how-heavy-is-qobject-really – dtech Apr 02 '13 at 11:54

0 Answers0