php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37891 memory leak
Submitted: 2006-06-22 18:20 UTC Modified: 2006-06-26 14:03 UTC
From: hannes dot magnusson at gmail dot com Assigned: dmitry (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2006-06-22 (CVS) OS: FreeBSD
Private report: No CVE-ID: None
 [2006-06-22 18:20 UTC] hannes dot magnusson at gmail dot com
Description:
------------
Can't seem to get the example any shorter...

Reproduce code:
---------------
<?php
class foo {
    public $arr = array();
    function foo(){
        $this->backtrace = debug_backtrace();
        call_user_func(array($this, "bar"));
    }
    function bar() {
        array_unshift($this->arr, debug_backtrace());
    }
}

$foo = &new foo;
?>


Actual result:
--------------
/usr/src/clean/php5/Zend/zend_execute.c(403) :  Freeing 
0x082F48E4 (16 bytes), script=/usr/local/php5/....
=== Total 1 memory leaks detected ===


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-26 14:03 UTC] dmitry@php.net
This code creates circular data structure. PHP doesn't free circular data structures at run-time and does free them on request shutdown (with warning about memory leak).

php-5.1 didn't store "$this object" in backtrace, so it didn't create circular data structure and worked fine.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 11:01:34 2024 UTC