Re: PHP Memory issues

From: Date: Tue, 23 May 2006 17:22:46 +0000
Subject: Re: PHP Memory issues
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6944@lists.php.net to get a copy of this message
If I have any memory leaking currently it is so minimal that I cannot detect it even after running the app for several days straight. On Tue, 23 May 2006, Madeleine D. wrote: > > Brian - > > I remember your postings from January, but I thought your conclusion was > that you had reduced the memory leak, but not eliminated it...? > > We don't find that the hardware makes much of a difference to the > leakage. The rate is about the same on a 233/80MB as it is on a 1.2G/2G > machine. > > One of the big differences is in the minimize behavior for NT-based > OS's, which I know has come up on the list before. However, that > doesn't do much for our Win98 installations, which we are stuck with. > That's where the globals and references have helped, but not eliminated > the problem. > > Madeleine D. > > > > > Brian A. Stumm wrote: > > >If you search the list archive for a post from me about memory you will > >find two sample scripts one with the memory leak and one without. The > >change to using global (reused) variables as opposed to creating new on > >the fly with each function call is exactly what fixed my problem. I dont > >*think* I have any memory issues at the moment. I've run my app for a few > >days at a time with my main routine being called once per second. I also > >stress tested the app by calling the main routine once each 50ms for 24 > >hour period. I noticed no increase in memory usage when testing on Linux. > >I've not done much memory testing on the windows side but the puter I'm > >using for windows would show it if it leaked. Its a celeron 333mhz with > >96MB Ram running Win98SE. > > > >On Mon, 22 May 2006, Madeleine D. wrote: > > > > > > > >>Andrew - > >> > >>I've been fighting this issue off and on for some time, w/o a lot of > >>definitive conclusions. I am hoping for a better life in PHP-Gtk2. > >>Something we have seen is that the leak behaves a lot differently > >>depending on the OS. We've had minimal problems w/ any of the NT's, and > >>a host of ones on Win98. > >> > >>Also, with a nod to Brian, all of our variables are global, and that > >>doesn't appear to make much of a difference, maybe because of the size > >>of our app. > >> > >>One thing I've come across recently was another developer's suggestion > >>that setting a variable to NULL (as in: $somevar = NULL), actually > >>released memory vs unset which, I agree, doesn't appear to do that at > >>all. I haven't had a chance to play with this yet, so I can't say one > >>way or the other if it works.... > >> > >>If you do try it, let us know if it makes a difference. > >> > >>Madeleine D. > >> > >> > >>Andrew Buczacki wrote: > >> > >> > >> > >>>I'm working on an app and recently I've noticed that there are > >>>substantial > >>>memory leaks no matter how I maneuver in the program. It almost seems that the > >>>memory isn't being freed by PHP when variables are no longer referenced or > >>>moved > >>>out of scope. I included a sandbox program that mildly resembles my app and the > >>>problem remains. I was wondering if someone who has experience with PHP memory > >>>allocation/management could take a look at my dummy code and find a solution to > >>>this issue. > >>> > >>>I recently found out about unset() and have been fiddling around with it, but it > >>>doesn't seem to free up the memory. > >>> > >>><?php > >>> > >>>if (!extension_loaded('gtk')) { > >>> dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); > >>>} > >>> > >>>class Page1 extends GtkLabel{ > >>> > >>>var $ary; > >>> > >>>function Page1() { > >>>$this->ary = array(); > >>>for($i=0;$i<1000;$i++) > >>> $this->ary[$i]=4242424242; > >>>$this->GtkLabel("This is Page 1"); > >>>} > >>>} > >>> > >>>class Page0 extends GtkLabel{ > >>> > >>>var $ary; > >>> > >>>function Page0() { > >>>$this->ary = array(); > >>>for($i=0;$i<1000;$i++) > >>> $this->ary[$i]=4242424242; > >>>$this->GtkLabel("This is Page 0"); > >>>} > >>>} > >>> > >>>class stupidobject { > >>> > >>> var $currPage; > >>> var $win; > >>> var $box; > >>> var $button; > >>> function stupidobject() > >>> { > >>> $this->currPage=0; > >>> $this->win = &new GtkWindow(); > >>> $this->button = &new GtkButton("Toggle"); > >>> $this->box = &new GtkHBox(); > >>> $vbox = &new GtkVBox(); > >>> $vbox->pack_start($this->box); > >>> $vbox->pack_start($this->button); > >>> > >>> $startlabel = &new GtkLabel("Start"); > >>> $this->box->pack_start($startlabel); > >>> $this->button->connect("clicked", array($this, > >>> "toggle")); > >>>// $this->button->connect("clicked", "toggle", $this); > >>> $this->win->add($vbox); > >>> $this->win->show_all(); > >>> } > >>> > >>> function toggle() > >>> { > >>> if($this->currPage == 1) > >>> $this->currPage = 0; > >>> else > >>> $this->currPage = 1; > >>> eval('$temp = &new Page'.$this->currPage.'();'); > >>> $child = $this->box->children(); > >>> //print_r($this->box); > >>>// print_r($child[0]); > >>> $this->box->remove($child[0]); > >>> unset($child[0]); > >>>// print_r($child[0]); > >>> //print_r($this->box); > >>> $this->box->pack_start($temp); > >>> $this->box->show_all(); > >>> } > >>>} > >>> > >>>$bob = &new stupidobject(); > >>> > >>>gtk::main(); > >>>?> > >>> > >>>

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