php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23548 Memory leak
Submitted: 2003-05-08 09:58 UTC Modified: 2003-05-14 11:04 UTC
From: neon at neon-line dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.3.2RC2 OS: Debian Linux
Private report: No CVE-ID: None
 [2003-05-08 09:58 UTC] neon at neon-line dot net
I'm still unable to create/locate code which causes this leak, but I'll give it as soon as I locate it. Because there is no use to paste tons of code. Bug was found while testing phpSysInfo script (propably in XPath.class).

/root/php4-STABLE-200304251730/Zend/zend_execute.c(489) :  Freeing 0x087D418C (12 bytes), script=/www/system/index.php
Last leak repeated 129 times
/root/php4-STABLE-200304251730/Zend/zend_execute.c(1214) :  Freeing 0x087D414C (12 bytes), script=/www/system/index.php
Last leak repeated 50 times
/root/php4-STABLE-200304251730/Zend/zend_execute.c(478) :  Freeing 0x087D410C (12 bytes), script=/www/system/index.php
Last leak repeated 52 times
/root/php4-STABLE-200304251730/Zend/zend_operators.c(1056) :  Freeing 0x087D4004 (32 bytes), script=/www/system/index.php
Last leak repeated 101 times
/root/php4-STABLE-200304251730/Zend/zend_hash.c(406) :  Freeing 0x087CE264 (35 bytes), script=/www/system/index.php
Last leak repeated 174 times
/root/php4-STABLE-200304251730/Zend/zend_execute.c(278) :  Freeing 0x087CE224 (12 bytes), script=/www/system/index.php
Last leak repeated 116 times
/root/php4-STABLE-200304251730/Zend/zend_operators.c(1049) :  Freeing 0x087CE084 (4 bytes), script=/www/system/index.php
Last leak repeated 70 times
/root/php4-STABLE-200304251730/Zend/zend_hash.c(178) :  Freeing 0x087CDEEC (32 bytes), script=/www/system/index.php
Last leak repeated 74 times
/root/php4-STABLE-200304251730/Zend/zend_execute.c(764) :  Freeing 0x087CDA84 (12 bytes), script=/www/system/index.php
Last leak repeated 261 times
/root/php4-STABLE-200304251730/Zend/zend_hash.c(440) :  Freeing 0x087CDE24 (64 bytes), script=/www/system/index.php
Last leak repeated 58 times
/root/php4-STABLE-200304251730/Zend/zend_hash.c(262) :  Freeing 0x087CDDC4 (41 bytes), script=/www/system/index.php
Last leak repeated 532 times
/root/php4-STABLE-200304251730/ext/xml/xml.c(262) :  Freeing 0x087CD7EC (8 bytes), script=/www/system/index.php
Last leak repeated 57 times
/root/php4-STABLE-200304251730/ext/xml/xml.c(258) :  Freeing 0x08690754 (12 bytes), script=/www/system/index.php
Last leak repeated 57 times
/root/php4-STABLE-200304251730/Zend/zend_API.c(678) :  Freeing 0x0869113C (12 bytes), script=/www/system/index.php
Last leak repeated 1 time
/root/php4-STABLE-200304251730/ext/xml/xml.c(512) :  Freeing 0x086910FC (11 bytes), script=/www/system/index.php
Last leak repeated 1 time
/root/php4-STABLE-200304251730/ext/xml/xml.c(648) :  Freeing 0x0868F504 (44 bytes), script=/www/system/index.php
/root/php4-STABLE-200304251730/Zend/zend_API.c(562) : Actual location (location was relayed)
/root/php4-STABLE-200304251730/Zend/zend_execute_API.c(341) :  Freeing 0x087B1ECC (44 bytes), script=/www/system/index.php
/root/php4-STABLE-200304251730/Zend/zend_variables.c(122) : Actual location (location was relayed)
Last leak repeated 3 times
/root/php4-STABLE-200304251730/ext/xml/xml.c(647) :  Freeing 0x0877A21C (12 bytes), script=/www/system/index.php
Zend/zend_language_scanner.c(4675) :  Freeing 0x086C1EEC (1 bytes), script=/www/system/index.php
/root/php4-STABLE-200304251730/Zend/zend_compile.c(1866) :  Freeing 0x086C1E4C (12 bytes), script=/www/system/index.php
Last leak repeated 3 times

Sorry that I can't give detailed description.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-08 10:04 UTC] edink@php.net
It is very difficult to determine anything without a short reproducing script. Could you try doing that?
 [2003-05-08 11:18 UTC] neon at neon-line dot net
I have been unable to create a short reproducing
script so far. Still working on it, but I have very litle information what might cause this memory leak. Still trying to figure that out.
 [2003-05-08 11:37 UTC] neon at neon-line dot net
Feel free to mark this back to Feedback status. Leak hapends after data has been sent and script is about to exit. I'm unable to reproduct the problem with a short script.
 [2003-05-08 11:59 UTC] moriyoshi@php.net
It looks like your script uses objects to represent some tree-like structure and those objects have circular references. That is,

<?php
class foo {
  var $childs;
  var $parent;
  function foo() {
    $this->childs = array();
    $this->parent = NULL;
  }
  function appendChild(&$child) {
    $this->childs[] = &$child;
    $child->setParent($this);
  }
  function setParent(&$parent) {
    $this->parent = &$parent;
  }
}

$a = &new foo();
$b = &new foo();

$a->appendChild($b);
?>

This causes awful leaks, but it's inevitable due to the language design; PHP employs reference-count based garbage collection.

 [2003-05-14 11:04 UTC] sniper@php.net
Not bug.

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 13:00:01 2026 UTC