You could try using memprof to see where the problem is occuring.  It
seems particularly good at finding these sort of problems.

It may also be worth adding a line like:
  g_message("theWindow refcount = %d", GTK_OBJECT(theWindow)->ref_count);
  g_message("xml       refcount = %d", GTK_OBJECT(theXML)->ref_count);

It may be that the objects aren't getting freed as their reference count
doesn't reach zero.  You should probably be using gtk_object_unref for the
GladeXML object.  Using destroy should be enough for the window.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


On Thu, 9 Mar 2000 [EMAIL PROTECTED] wrote:

> Greetings..
> 
> I wrote the code below in an effort to test out loading/unloading toplevel
> widgets from the glade file. It works fine, *except* for the fact that once
> I have loaded a window, i am never able to recover the memory used by loading
> it -- even tho the window disappears from the screen when i call 
> gtk_widget_destroy on it (which suggests to me that the ref count == 0).
> 
> I am also trying to release the GladeXML object (see void button_click)
> so that it will release the parse tree. Watching it in gtop tho, the memory
> it uses to load the window does not decrement when i call gtk_object_destroy.
> 
> Thanks again. Any insights would be appreciated. Code following.
> 
> D.
> 
> --
> 
> #include <glade/glade.h>
> #include <gtk/gtk.h>
> 
> #include <iostream>
> 
> GladeXML *theXML;
> GtkWindow *theWindow;
> 
> extern "C" {
> void button_click()
> {
>      if (theXML == NULL)
>      {
>         theXML = glade_xml_new("test.glade", "window2");
>         theWindow = (GtkWindow*)glade_xml_get_widget(theXML, "window2");
>         gtk_window_set_title(theWindow, "blah");
>      }
>      else
>      {
>         cerr << "Window release..."<< endl;
>         gtk_widget_destroy(GTK_WIDGET(theWindow));
>         gtk_object_destroy(GTK_OBJECT(theXML));
>         theXML = NULL;
>      }
> }
> }
> int main(int argc, char** argv)
> {
>      GladeXML *xml;
> 
>      gtk_init(&argc, &argv);
>      glade_init();
> 
>      xml = glade_xml_new("test.glade", "window1");
>      glade_xml_signal_autoconnect(xml);
> 
>      theXML = NULL;
> 
>      gtk_main();
>      return 0;
> }
> 
> +---------------------------------------------------------------------+
> To unsubscribe from this list, send a message to [EMAIL PROTECTED]
> with the line "unsubscribe glade-devel" in the body of the message.
> 


+---------------------------------------------------------------------+
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the line "unsubscribe glade-devel" in the body of the message.

Reply via email to