[PHP-GTK] Freeing up memory when objects drop out of scope
by Andrew Buczacki other posts by this author
Jun 30 2006 1:32PM messages near this date
Re: [PHP-GTK] accelerators and stock items - working or not working?
|
Re: [PHP-GTK] Freeing up memory when objects drop out of scope
So I'm still bashing my head against a nasty memory leak that's been plaguing me
for the past few months. The program contains a manager class that oversees
several small, customizable "screen content" classes. Each screen has its own
load of assorted widgets, containers, and pixmaps, which are all shoved into a
box which is inserted into the page. When the user navigates from one screen to
the other, the manager destroys the old screen content object and creates the
next one in the list. The problem is that my program is leaking substantial
memory per "screen swap" (anywhere from 120k-8mb(!!!)) depending on the page.
I've had several people go over my code and it doesn't have any apparent memory
leaks.
I guess my question is how do I _know_ that when the object is "destroyed" all
of its internal memory is freed properly? Shouldn't the screen drop out of
scope and free up all the memory it used when I navigate away from it? I don't
think there are any other references to a page aside from the object itself (via
$this) and the manager class. Could it be the page is being freed, but the
internal objects are still floating around in memory? I've even tried the
following
$this-> memvar1 = NULL;
$this-> memvar2 = NULL;
..
$this = NULL;
(where each variable (including GTK objects) is a member variable
(in the manager class)
unset($this-> screenvar);
$this-> screenvar = NULL;
.. and it still leaks the same amount of memory! Is there some obscure
referencing issue that I'm not aware of, like passing objects by reference
creating local copies or not freeing up memory?
Sorry if this post seems too full of questions, but I'm at my wit's end. I'm
about to make each screen its own GTK app in a desperate attempt to curb some of
these memory problems. If anyone can offer new insight to my problem, it would
be much appreciated.
Andrew
P.S. Someone replied to an earlier thread I posted to this list and he said
that PHP-GTK cannot free up memory in member variables of classes. His
suggestion was to make every variable global and reuse as many as possible, but
that's just not viable for my purposes. Is there an alternative to this? Is
this a documented bug/feature?
--
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Andrew Buczacki
Andrei Zmievski
Andrew Buczacki
Andrei Zmievski
Christian Weiske
Andrew Buczacki
Christian Weiske
|