Re: [GD-General] Multiple Inheritance and RTTI
Brought to you by:
vexxed72
From: Noel L. <ll...@co...> - 2003-02-04 23:06:17
|
On Tue, 04 Feb 2003 14:43:36 -0800 brian sharon <pud...@po...> wrote: > Question: there were references to code bloat produced by RTTI. Is that > really a big issue? It's just some bytes added per vtable - I'm > wondering if anyone's measured it to come up with a more exact number > than that. You are right, it is probably not all that significant. I haven't measured it, and it can vary from implementation to implementation, but it's not going to amount to a lot of memory. Most implementations add one extra entry to the vtable to every class that already has a vtable (if a class doesn't, you're not treating it polymorphically, so you don't need RTTI). So that's one dword per class. Big deal. In addition to that you have the actual information kept by each class. At least it's going to be the information contained in the type_info structure: decorated class name and sequence number. It probably has some other internal data. Even so, we're probably talking about 100 bytes per class? At a round 128 bytes per class, if you have 1000 classes with virtual functions, it will take 128 KB. So it's not totally peanuts in the case of a console with 32 MB or even 64 MB, but it's not a huge amount. Still, that's with 1000 different polymorphic classes, which is probably way on the high end for a normal game today. I'd guess that a lot of games are only using more on the order of a hundred polymorphic classes, which brings it down to a more reasonable 15-20 KB. Having said all that, I still don't like using C++'s RTTI for getting the interface pointers to classes. I prefer using the custom QueryInterface function we talked about. And for regular RTTI, I much prefer a custom system. They are so simple to implement too, that with the added flexibility they provide, there's almost not reason not to. --Noel ll...@co... |