#37787 [Opn->Csd]: Memleak when using timeout in a class
| From: | andrei@php.net | Date: | Thu, 15 Jun 2006 04:28:45 +0000 |
| Subject: | #37787 [Opn->Csd]: Memleak when using timeout in a class | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3032@lists.php.net to get a copy of this message | ||
ID: 37787
Updated by: andrei@php.net
Reported By: cweiske@php.net
-Status: Open
+Status: Closed
Bug Type: PHP-GTK related
Operating System: Linux
PHP Version: 5.1.4
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-06-12 13:06:32] cweiske@php.net
Description:
------------
PHP-Gtk leaks memory when using a timeout in a class. It doesn't leak
when not using a class.
Reproduce code:
---------------
<?php
//This code leaks
class MemTest extends GtkWindow
{
public function __construct()
{
parent::__construct();
Gtk::timeout_add(100, array($this, 'shoot'));
}
public function shoot()
{
static $t = 0;
if (++$t == 1) {
Gtk::main_quit();
}
return true;
}
}
$mag = new MemTest();
$mag->show();
Gtk::main();
?>
Expected result:
----------------
<?php
//This code does not leak
Gtk::timeout_add(100, 'timeout');
function timeout() {
static $t = 0;
if (++$t == 5) {
Gtk::main_quit();
return false;
}
return true;
}
Gtk::main();
?>
Actual result:
--------------
cweiske:/data/cvs/phpgtk2/test> p5 memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(930) : Freeing
0x08E085EC (35 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(383) : Actual location
(location was relayed)
Last leak repeated 3 times
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(846) : Freeing
0x08E019A4 (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(866) : Freeing
0x08E0190C (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(921) : Freeing
0x08E01884 (32 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(169) : Actual location
(location was relayed)
Last leak repeated 1 time
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_execute_API.c(644) : Freeing
0x08E0131C (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(990) : Freeing
0x08E0122C (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
ext/gtk+/gtk.overrides(273) : Freeing 0x08E00CB4 (32 bytes),
script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(169) : Actual location
(location was relayed)
Last leak repeated 1 time
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
ext/gtk+/gtk.overrides(272) : Freeing 0x08E009D4 (16 bytes),
script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_vm_execute.h(4190) : Freeing
0x08E03F7C (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_vm_execute.h(3438) : Freeing
0x08E011D4 (35 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(383) : Actual location
(location was relayed)
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_vm_execute.h(3407) : Freeing
0x08E0030C (16 bytes), script=memleak_device_get_state.phpw
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_vm_execute.h(12588) : Freeing
0x08E002B4 (35 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(383) : Actual location
(location was relayed)
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_vm_execute.h(12538) : Freeing
0x08E08144 (32 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_hash.c(169) : Actual location
(location was relayed)
Last leak repeated 1 time
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/php/php-5.1.4/Zend/zend_variables.h(45) : Freeing 0x08DE61A4
(6 bytes), script=memleak_device_get_state.phpw
/data/cvs/php/php-5.1.4/Zend/zend_variables.c(120) : Actual location
(location was relayed)
[Mon Jun 12 15:07:13 2006] Script: 'memleak_device_get_state.phpw'
/data/cvs/phpgtk2/php-gtk/main/php_gtk_util.c(873) : Freeing
0x08DE088C (53 bytes), script=memleak_device_get_state.phpw
=== Total 21 memory leaks detected ===
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37787&edit=1