Page 1 of 1

php commandline: memory size exhausted

Posted: Tue Aug 03, 2010 12:25 pm
by ^rooker
[PROBLEM]
Just ran into the following error:

Code: Select all

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 1817779 bytes) in /home/ferry/mthk/trunk/src/include/MthkXML.php on line 180
Caused by a call to php-tidy's "parseString()" function.

[SOLUTION]
Although there was a known issue with php5-tidy regarding bad memory management (Debian bug tracking: #463872, 464074), it was simply bad programming in my case:

I had a hidden recursion that caused the generated XML to grow beyond reasonable size.

To figure that out, I just saved the to-be-parsed XML-string into a temporary file:

Code: Select all

file_put_contents('/tmp/xml-tidy-debug.xml', $xml_string);
So, if you also run into this error, maybe you should also check the xml string you're forwarding to tidy->parseString(). ;)