Re: PHP Gtk::timeout_add memory leak future information

From: Date: Tue, 10 Sep 2002 00:42:41 +0000
Subject: Re: PHP Gtk::timeout_add memory leak future information
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2407@lists.php.net to get a copy of this message
On Mon, Sep 09, 2002 at 05:45:45PM +0200, Sander Aerts [SQAD Visual Multi-Media] wrote: > Here i am again about the memory leak, you can use the following code > to emulate the leak: > <? > dl("php_gtk.dll"); > function triggerme(){ > gtk::timeout_add(100, 'triggerme'); > } > gtk::timeout_add(100, 'triggerme'); > gtk::main(); > ?> > When you run this code the memory usage will increase with 8 kilobyte > everytime when the gtk::timeout function is called... Your code is defective. You are using gtk::timeout_add incorrectly. Increase in memory is expected. Memory usage is supposed to increase for every timeout you add. Why are you adding so many timeouts recursively? Once is enough, surely? The timeout function will continue to be called until your code returns FALSE from the triggerme() function. Then it will be removed. http://developer.gnome.org/doc/API/gtk/gtk-general.html#GTK-TIMEOUT-ADD "Registers a function to be called periodically. The function will be called repeatedly after interval milliseconds until it returns FALSE at which point the timeout is destroyed and will not be called again." Add a "return FALSE;" if you don't want triggerme to be called again. -- James Cameron mailto:quozl@us.netrek.org http://quozl.netrek.org/

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