[Glade-users] why using libglade is better...

On Mon, 2004-10-18 at 19:23, Christopher Cramer wrote:
On Mon, Oct 18, 2004 at 01:29:12PM -0400, Tristan Van Berkom wrote:
If you want to re-create the popups every time you use them then you'll
need to seperate them into seperate glade files, this way you will gain
on RAM but loose on CPU (because your program will have to reload the
glade file every time for your popup).

You don't actually need to put them into a separate file to be able to
recreate them. What I do is put them all in the same file, and only load
the widget (the main app window, a dialog window, etc.) that I need,
using the root argument to glade_xml_new().

The documentation for glade_xml_new() says, "Note also that the XML
parse tree is cached to speed up creating another GladeXML object for
the same file", so it shouldn't actually have to reload the glade file
for every popup. It certainly seems to me that the startup (when it loads
the main app window from the glade file) is quite a bit slower than the
popup creation, although I haven't profiled it.

It says that, but I can't see the code which reuses the loaded data
(i.e. the GladeInterface). It just looks like wasted memory at the

So for people using libglade I'd suggest:

 1) Use a separate XML file for each window/dialog. Otherwise when you
    call glade_xml_new() on a file it parses the whole file. Also if
    you don't pass a root element to create it creates one of each
    window/dialog, which is also wasteful.

 2) Don't keep GladeXML objects around. Load the Glade XML file, get
    pointers to the widgets you need, then unref the GladeXML object.


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