php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37787 Memleak when using timeout in a class
Submitted: 2006-06-12 13:06 UTC Modified: 2006-06-15 04:28 UTC
From: cweiske@php.net Assigned:
Status: Closed Package: PHP-GTK related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
 [2006-06-12 13:06 UTC] 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 ===


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-15 04:28 UTC] andrei@php.net
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.


 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 22:03:43 2022 UTC