Re: [gtk-list] Re: Gtk-- versus GTK+



In message <37301EC7.407D80D7@alna.lt>Martynas Kunigelis writes
>Joe Pfeiffer wrote:
>> 
>>    - Gtk-- is oversized,
>> 
>> I don't see how.  It's about as small a wrapper as I can imagine.
>
>Come on. Do cout << sizeof (Gtk_FontSelectionDialog) << endl; 22K per
>widget on ia32 is as small as you can imagine?

FontSelectionDialog is not a perticularly small widget.  The base size
is not nearly 22K.  But moreover, using sizeof to measure the size
of a widget is not a perticularly good measure.  If you apply that
measure to a gtk+ widget you will find it is realitively small thus
leading you to think that Gtk-- is horribly bloated.  
After all how could a wrapper of something be so much larger that
the thing it wraps?  

The problem (with measurement) is that with Gtk+ much of the data 
is in hash tables.  These hash tables don't appear as more that 1
pointer in the size of a gtk+ object.  Thus any meaure of the size
of an gtk+ widget that does not add up the size of all of the
various memory pieces associated with that object is very inaccurate.
As a wrapper we need to wrap all the entry points into these tables.
There are a lot of entry points and thus a lot of size.  (On
the other hand Gtk+ could help greatly with this if
they cared to.  Many widgets are artifically large because the choice
of placement in the tree.  For example a seperator really doesn't need
half the signals that it contains.  A good gadget/widget seperation
would greatly help the size of gtk+ objects.)

Second (and more fundimental) is the way the gtk+ signals act.  
They are a per object type of class.  However, in C they
require the user to specify them directly with all of this
information.  On the other hand it is expected that a C++ object
knows who the object is.  So we don't get to ask the user who owns
the signal.

C:
  gtk_signal_emit_by_name(GTK_OBJECT(foo),"sig",data);

C++:
  foo.sig(data);

So although it appears that the user supplied the name of the object 
to C++, that information is not available to the program.  (The compiler
had it, but we cant access it).   The result is that every signal
increases the size of the C++ wrapper by 12 bytes.  (And this is the
per object portion you are measuring)  4 bytes to name the object,
4 bytes to name the signal, 4 bytes to name emit function.  There
are a lot of signals in gtk+ so this makes up the bulk of a gtk-- 
object.

So sorry for the lecture, however, there is a reason for all the
space that Gtk-- takes.  We are actively working on driving this
cost down however, that will come with that cost of compiling
hundreds of little static functions (that will not get counted in
sizeof)  With some luck I can cut the cost down to 4 bytes per
signal.  Unfortunately that is as small as it goes.

Please feel free to come help, it is always appreciated.

--Karl 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]