Re: Freeing up memory when objects drop out of scope

From: Date: Fri, 11 Aug 2006 20:22:29 +0000
Subject: Re: Freeing up memory when objects drop out of scope
References: 1 2 3  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7088@lists.php.net to get a copy of this message
If you can reproduce this memory leak using a short script, I'll happily take a look at it. -Andrei On Aug 11, 2006, at 11:05 AM, Andrew Buczacki wrote:
Quoting Andrei Zmievski <andrei@gravitonic.com>:
Sorry for a delayed reply.
What kind of object is this "screen"? GtkWindow? Yes, and this is by design (for some objects). Most of the objects like GtkButton, etc will be auto-destructed once they drop out of scope. However, there is a handful (like GtkWindow, and others which I can't remember now) that behave differently. These objects may have internal references held to them from parts of Gtk+. So when a GtkWindow drops out of scope, we check whether the refcount > 1 and if so, we make the internal GtkWindow object "own", that is, hold a reference to its wrapper. Then, if the refcount on the wrapper or the internal object is decreased further, everything is cleaned up. Basically, you shouldn't really worry about memory management in PHP- GTK aside from being aware of this issue. Did you try $this->screenvar->destroy()? -Andrei
I've since done a complete overhaul of the code, and now our memory issues are supressed, if not gone completely. In my example, the screen was a GtkHBox which was swapped in and out of a single window. There was a manager class that would destroy the current screen (box) and create the next one in the sequence. Since our memory requirements were rather low and based on the design of the program we can't front-load all the content. Now, however, I've reduced each screen to its own PHP application. There's still a manager, but it makes php calls instead of swapping. Using the destroy() method didn't seem to free up any more memory than the other methods I tried. Sorry if this seems vague, but I don't really remember the old code, since this new stuff is radically different. Andrew --PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.general (#7088) next »