Re: Memory issues
| From: | Malk0 | Date: | Mon, 13 Dec 2004 12:25:34 +0000 |
| Subject: | Re: Memory issues | ||
| References: | 1 2 3 4 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5349@lists.php.net to get a copy of this message | ||
I've encountered this problem in a Multiple Documents Interface apps
and after a little search it appears that this is due to the way that
php 4 manage objects, as it was made for webpages the objects are
never really destroy from memory until the end of the script. This
isn't really a problem when you running a single script on a webserver
to display a webpage. but this is a real problem when you're running a
desktop apps which won't stop after 30sec but only when you have
finished your job.
For my part to minimise this problem i try to use some static vars when i can
ex:
function show_dialog(){
static $dialog;
if(! is_a($dialog,'gtkdialog'))
$dialog= &new gtkdialog();
$dialog->show_all();
$dialog->hide_all();
}
this is a good way if you never have more than one dialog on screen
but won't be usable if you want more than a dialog generate by that
function. All your dialog would be the same.
Another way would be to launch the dialog in an other process either
using the pnctl extension (i've never get it work) or by a popen()
that launch another php instance and another prog. the problem: php
gtk will be load again so it will take some memory but when the second
program (you dialog box for example) will be destroy the memory will
really be free.
I Hope too that php5 will resolve this BIG problem (i'm really witing
for), either i will use python.
best regards to all,
--
-- Malk0 --
venez discuter php-gtk en francais ici http://mk0phpgtk.xgarreau.org