#103 Memory leak, php crash

open
nobody
None
5
2015-01-23
2012-04-04
Daniloffff
No

Have php crash when processing a lot amounts of data.
tested on PHP v2.3.8 and 2.4.0

for fix problem need to replace this function

// clean up memory due to php5 circular references memory leak...
function clear()
{
    $this->dom = null;
    $this->parent = null;
    $this->parent = null;
    $this->children = null;
}

on this:
// clean up memory due to php5 circular references memory leak...
function clear()
{
unset($this->dom);
unset($this->parent);
unset($this->parent);
unset($this->children);
}

Discussion

  • Daniloffff
    Daniloffff
    2012-04-04

    php version 5.3.8 and 5.4.0 ;)

     

  • Anonymous
    2012-04-08

    Thanks alot! I was going crazy with a Segment Fault and this did the jobb!


    I cannot add a new comment but only edit an existing one:
    I have spend over a day finding my bug. Was writing a script in windows and testing it with xampp. It did not give me a segmentation error. Eventually I installed VMware Player and installed Debian in a virtual machine with apache and mysql. That gave me a segmentation error in the error log which led me to this ticket. Finally I fixed the bug!

     
    Last edit: Anonymous 2014-04-03

  • Anonymous
    2012-04-27

    This actually didn't work for me, but when I removed all the lines from the method it started to work again.

     

  • Anonymous
    2012-06-06

    Can confirm. After this update "segmentation fault: 11" & "zend_mm_heap corrupted" errors are gone.

    [2012-11-16: Why can I edit this comment but not post a new
    one? My question: Is there a test case and has this bug been
    reported in the official bug tracker https://bugs.php.net/ ?
    If not why not?]

     
    Last edit: Anonymous 6 days ago
  • fedu
    fedu
    2012-12-03

    Yes! This solved my problems :) Good call!

     
  • John Schlick
    John Schlick
    2012-12-30

    Please give me a test case for this (as in a web page that "generally" causes these memory errors, an once I test it, I'll update the code.

    However, I note that the newest version of the code has:
    function clear()
    {
    $this->dom = null;
    $this->nodes = null;
    $this->parent = null;
    $this->children = null;
    }

    Are you using the most current version of the code?

     
  • Tobias Heide
    Tobias Heide
    2013-02-24

    Thanks a lot! Solved my problem!

     
  • Ivan Vulovic
    Ivan Vulovic
    2014-11-16

    I am still getting same error (Segmentation fault), using php 5.5 version, with 4 threads.

     
    Last edit: Ivan Vulovic 2014-11-16