[osg-users] Change to Optimizer OptimizationOptions

Peter Hrenka p.hrenka at science-computing.de
Tue Nov 3 23:57:25 PST 2009

Hi Chris,

Chris 'Xenon' Hanson schrieb:
> Peter Hrenka wrote:
>> Nothing needs to be virtual here. It's just a template class
>> with overloaded operators which means everything is effectively
>> inlined. We could also use an "unsigned int" as internal storage type
>> (Qt seems to use a signed int).
>   But doesn't RTTI embed a hidden pointer (similr to the vftbl) into every class as well,
> that points to the common per-class ID/metadata?

Boy, you're paranoid. Well, sometimes that's a good thing ;-)

My understanding is that as long as you do not have virtual
methods or derive (directly or indirectly) from a class that
has virtual methods, there is no overhead in the memory layout
of the class instances.

But of course, I cannot guess what stange compilers will do...
The example programm gives me the following output on
64-bit gcc on Linux:

EnumSize: 4
EnumFlagsSize: 4
EnumFlagsArraySize: 40
PlainClass: 4
VirtualClass: 16

So the template class does not use more memory than the plain enum
(on this platform).

>   I guess quibbling about an extra pointer is very old-skool 80s coder of me. You can have
> my VIC-20 when I'm done porting OpenGL ES 1.0 to it! ;)

No, your concerns are valid. As you can see the virtual method adds a 
factor of 4 in memory usage to the "VirtualClass" as compared
to the "PlainClass" in the example.



Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Roland Niemeier, 
Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Michel Lepert
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: enumFlags.cpp
Type: text/x-c++src
Size: 737 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20091104/c59ab7ab/attachment.cpp>

More information about the osg-users mailing list