Memory leak problem
| From: | Yann Le Guennec | Date: | Mon, 15 Jul 2002 12:59:06 +0000 |
| Subject: | Memory leak problem | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-2249@lists.php.net to get a copy of this message | ||
I just started using Php-Gtk, but I already know Gtk+.
Here is a small script I wrote and for every three clicks on
the drawing area, the script grows by about 4Kb of memory.
Is there something wrong with the code or is there
a problem with the php-gtk library ?
There also seems to be no way to destroy a drawing area.
A script like the scribble.php shipped with the php-gtk distribution
make the X server go burst in about 30s to 1min of resizing.
Because it creates a new drawing area for each resize event,
without releasing the previous one.
(Note: I have 512Mb of memory plus about the same in swap,
that should be enough to run the scribble ;-)
Version : PHP 4.2.1, PHP_GTK 0.5.1
Yann.
--------------------------------------------------------------
#!/usr/bin/php
<?
if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
dl('php_gtk.dll');
else
dl('php_gtk.so');
}
function button_press($object,$event)
{
};
$draw = &new GtkDrawingArea();
$draw->connect('button_press_event', 'button_press');
$draw->set_events( GDK_BUTTON_PRESS_MASK );
$draw->show();
$win = &new GtkWindow();
$win->set_title('Leak test');
$win->set_usize(600,250);
$win->connect_object('destroy', array('gtk','main_quit'));
$win->add($draw);
$win->show();
Gtk::Main();
?>
-------------------------------------------------------------