php commandline: memory size exhausted

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

php commandline: memory size exhausted

Post 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(). ;)
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply