I am looping over a large number of XML files, parsing them, and adding their data to an Oracle database. After the thing runs for a set time-limit it always and without fail terminates with a WARNING and then a FATAL memory allocation error. the WARNINGs occur on the simplexml_load_string() line:
Warning: simplexml_load_string() [function.simplexml-load-string]: Memory allocation failed : growing buffer in c:\Inetpub\wwwroot\importer0.1\ECCImport.php on line 304
line 304: $sx = simplexml_load_string($buf);
and the FATAL:
FATAL: emalloc(): Unable to allocate 15116551 bytes
to try and combat this, as each iteration of the loop terminates, i explicitly unset($sx) and unset($buf). this should not be necessary due to their reassignment at the top of each loop, but it actually did help a little.
I realize that i can increase memory_limit in php.ini, but i fear this will just postpone the issue w/o me solving it. I believe each iteration of my loop should start with a clean memory slate (and thus consume a predictable and small amount of memory).
Now i am totaly stumped. Is there a memory leak in the function, or is it likely elsewhere in my code? has anyone come across this behavior in their own code with the new XML handling functions?
Thanks,
Mark.