2

I'm trying to parse an HTML file with simplehtmldom and I'm getting this error:

zend_mm_heap corrupted

after about 4 seconds of execution on a 8231 lines HTML file. Could this be a bug or just excessive memory usage?

Matteo Riva
  • 24,728
  • 12
  • 72
  • 104

2 Answers2

5

There is a bug that affects most PHP5.2 and above, and can (albeit not always consistently) affect any application that works with large numbers of objects, particularly when the server is heavily loaded; but does leave a "zend_mm_heap corrupted" message in the apache logs.

One possible solution is to add the line: export USE_ZEND_ALLOC=0 to the apache envvars file

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • Yep that got rid of the error, but does that mean that the script is using too much memory? I have problems getting simplehtmldom to work on that file. – Matteo Riva Oct 01 '10 at 06:50
  • Too much memory generally triggers an out of memory error; and I think that if it was that simple, the PHP dev team would have been able to fix it by now... but this seems an intermittent error triggered when PHP is allocating too many small chunks of memory very quickly, and the memory used by the many objects is fragmenting – Mark Baker Oct 01 '10 at 07:41
  • I'm experiencing exactly the same problem and I tried disabling the Zend Memory Manager as suggested. That was not helping, however. With USE_ZEND_ALLOC=0 I'm no longer getting the "zend_mm_heap corrupted" error but the Apache process segfaults instead. – cg. Oct 25 '10 at 14:47
  • Yes - this fixed the zend_mm_heap corrupted error for me (PHP 5.3.3). I am now getting glibc errors outputting in apache log - but the php app works so now it is time for more research on my new problem... – caligoanimus Apr 11 '11 at 16:57
4

I found it on the SF homepage of the simplehtmldom:

change the 4 lines of code in simple_html_dom.php (that works for me)

// clean up memory due to php5 circular references memory leak...
function clear()
{
    unset($this->dom);
    unset($this->nodes);
    unset($this->parent);
    unset($this->children);
}
cidious
  • 41
  • 2
  • 1
    The solution here is better, and seems to be a reliable source: http://sourceforge.net/p/simplehtmldom/patches/3/ – Ulflander Dec 21 '12 at 14:23
  • 1
    So lame they still didnt fix memory problems... I tried everything untill I broke my installation... I made a clean format and now I just found this xD @Ulflander, thks <3 – Enissay Jul 31 '13 at 15:24