PHP Memory issues

From: Date: Mon, 22 May 2006 21:44:19 +0000
Subject: PHP Memory issues
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6934@lists.php.net to get a copy of this message
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 (#6934) next »