Re: Changing font colors on the fly == memory leak!

From: Date: Tue, 03 Jan 2006 08:24:31 +0000
Subject: Re: Changing font colors on the fly == memory leak!
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6495@lists.php.net to get a copy of this message
HI, What a bad news :-/ I thought that even in a web environment it's always a good thing to be abble to really free some memory when not needed any more. This permitt to support more charge on the server. And as you said a lot of us use php to make CLI apps or even php-gtk apps that really need to free some memory. Hope this will change in a near future as imho it's the last point that let people called php a 'toy' :( happy new year to all, nathan. 2006/1/3, Steph Fox <steph@zend.com>: > Nope, it isn't entirely fixed in PHP-GTK 2, because it isn't 'fixed' in PHP > 5.1. Tho' memory usage is less of an issue in GTK 2 and PHP 5... > > There have been some interesting discussions about this-all on the PHP > internals list fairly recently. I'll post more when I have something more > positive to post; basically the consensus at present is that PHP is designed > for the internet, rather than for clientside applications, but it looks (to > me) as if that consensus might be shifting gradually - primarily because a > lot of people use the CLI sapi. > > - Steph > > > ----- Original Message ----- > From: "Nghia" <nghia.ho@norwood.com.au> > To: <php-gtk-general@lists.php.net> > Sent: Tuesday, January 03, 2006 6:51 AM > Subject: RE: [PHP-GTK] Changing font colors on the fly == memory leak! > > > >I posted a similar problem of memory leaking a while ago. I think the > > consesus is that php4 doesn't free any memory until the script ends. This > > might be fixed in the php gtk2. You can try and minimize the problem by > > declaring objects once globally, and perhaps restart your process > > periodically if possible. > > > > -----Original Message----- > > From: Brian Stumm [mailto:bstumm@energytechnologysystems.com] > > Sent: Friday, 30 December 2005 7:22 AM > > To: php-gtk-general@lists.php.net > > Subject: [PHP-GTK] Changing font colors on the fly == memory leak! > > > > > > I must be doing this wrong. My method results in a memory leak. Below is > > some output from ps aux under linux showing the memory usage climbing > > steadily. Below that is a sample app demonstrating the memory leak. Is > > there a different way to change font colors? > > > > I'm positive that this increase in memory usage is not temporary and > > does not reach some maximum level and hold. The sample app is based on a > > much larger app I'm working on. In that version the memory usage goes as > > high as (approx) 65% of 256MB total avail after 80 some hours of run > > time. This testing is done on a box with 1 GB of RAM available. In just > > 20 mins memory usage goes as high as 30MB. The sample app updates every > > 50ms, my real application updates once a second. The faster update rate > > was just used to highlight the memory leak with a shorter test run time.. > > The 80 some hours of runtime mentioned before was while I was away from > > work over the holiday weekend and using a cronjob I logged the memory > > usage periodically throughout the weekend. > > > > Output from ps aux: > > Thu Dec 29 11:56:37 EST 2005 > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > > > > bstumm 16589 0.6 1.4 19344 15188 pts/4 S+ 11:49 0:02 php > > leak.php > > Thu Dec 29 12:00:14 EST 2005 > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > > > > bstumm 16589 0.6 1.8 23568 19364 pts/4 R+ 11:49 0:04 php > > leak.php > > Thu Dec 29 12:05:44 EST 2005 > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > > > > bstumm 16589 0.5 2.5 30432 26316 pts/4 R+ 11:49 0:05 php > > leak.php > > Thu Dec 29 12:09:24 EST 2005 > > USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > > > > bstumm 16589 0.5 2.9 35052 30860 pts/4 S+ 11:49 0:06 php > > leak.php > > > > > > FILE: leak.php > > <?php > > /* Load php-gtk library */ > > if (!extension_loaded('gtk')) { // Load the GTK Extension > > dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); > > } > > > > ############### > > ## Functions ## > > ############### > > > > /***** DELETE_EVENT() *****/ > > // Called when delete-event happens. Returns false to indicate that the > > event should proceed. > > function delete_event() { > > return false; > > } > > > > /***** DESTROY() *****/ > > // Called when the window is being destroyed. Simply quit the main loop.. > > > > function destroy() { > > global $fp; > > if($fp) { > > fclose ($fp); > > } > > while(Gtk::events_pending()) { > > Gtk::main_iteration(); > > } > > Gtk::main_quit(); > > die(); > > } > > > > /***** UPDATESCREEN() *****/ > > function UpdateScreen() { > > while(Gtk::events_pending()) { > > Gtk::main_iteration(); > > } > > return true; > > } > > > > /***** MAIN() *****/ > > function main() { > > global $z1t, $st1, $yellow, $green; > > > > $num = RAND(1,10); > > > > $st1 = $st1->copy(); > > > > if($num < 5) { > > $st1->fg[0]=$yellow; > > } else { > > $st1->fg[0]=$green; > > } > > $z1t->set_text($num); > > $z1t->set_style($st1); > > > > UpdateScreen(); > > > > return true; > > } > > > > ################# > > ## Main Window ## > > ################# > > $green=&new gdkcolor('darkgreen'); > > $yellow=&new gdkcolor('darkgoldenrod'); > > > > $window = &new GtkWindow(); > > $window->connect('destroy', 'destroy'); > > $window->connect('delete-event', 'delete_event'); > > $window->set_policy(0, 0, 0); > > $window->set_border_width(0); > > $window->set_title($window_title); > > $window->set_name('MainWindow'); > > $window->set_usize(400,300); > > $window->set_position(GTK_WIN_POS_CENTER); > > $window->realize(); > > > > $layout = &new GtkLayout(null,null); > > $window->add($layout); > > > > // Box Container - Absolute Positioning > > $box = &new GtkFixed(); > > $box->set_border_width(10); > > $layout->put($box,0,0); > > $box->show(); > > > > $z1t = &new GtkLabel(''); > > $st1 = $z1t->style; > > $box->put($z1t,10,10); > > > > $window->show_all(); > > > > ############################### > > ## Hand off to GTK Main Loop ## > > ############################### > > // register our main loop/function so it gets processed each 50ms. > > gtk::timeout_add(50, 'main'); > > gtk::main_iteration(); // one refresh > > Gtk::main(); // Away we go weeee! > > > > ?> > > > > -- > > Brian Stumm > > ETS - Energy Technology Systems, Inc > > bstumm@energytechnologysystems.com > > http://energytechnologysystems.com > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > > PHP-GTK General Mailing List (http://gtk.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > __________ NOD32 1.1349 (20060102) Information __________ > > > > This message was checked by NOD32 antivirus system. > > http://www.eset.com > > > > > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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