Re: Memory issues
| From: | Gonzalo Monzón | Date: | Mon, 13 Dec 2004 19:08:53 +0000 |
| Subject: | Re: Memory issues | ||
| References: | 1 2 3 4 5 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5357@lists.php.net to get a copy of this message | ||
Malk0 wrote:
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 Hi to all,Thank you for the replies, Christian and Malk0, but I'd like to ear something about the second thing I was talking, and the really strange one. Let me explain it again so you can understand me: I already know about the memory issues, and so I use global arrays for setting all the widget stuff there. I always re-use the same variables on the global arrays for each unique window lets say it this way... when only I want to have an instance in memory -i.e. a simple dialog- I always instantiate it in the same var for minimizing memory waste. For top windows wich I want to have multiple instances, I store them in the global array too but adding to the item name plus an extra id. like window num. so each time I set it in "new" memory and each destroyed window doesn't release memory. Ok, that's the known behaviour with php4 - gtk1. As you said, we must accept it. Ok, but what I really don't know about is this: Once you have a php-gtk app running in memory, using ie. 16Mb memory -since here all is ok, you're working on the gui php application- but if then do I click on the taskbar and release the command line window from wich I've lauched previously the app -where the php app. does all the stdout-, some times at first or other times for second time, this causes two strangely change the memory usage of the app from 16Mb down to 200kb... ? Anyway the app continue running and all ok, but memory usage in the win2k task manager changes from 16MB to 200kb suddently releasing the command line... somebody knows why? Sorry my bad english... I hope now I've exposed this strange behaviour a bit better... Sincerely, Gonzalo Monzón