I need to parse a very big XML file, with a filesize of 750Mo !
I have meomy limit at 512M
ini_set('memory_limit', '512M');
I have no problem to open file under 30Mo, but with 750Mo, I obtain a fatal error
Fatal error: Allowed memory size of 1677721600 bytes exhausted (tried to allocate 2988843769 bytes)
I do that to open files :
$fichier = file_get_contents($inputfileName);
$xmlInput = simplexml_load_string(utf8_encode($fichier));
Have you an idea to open this file ?
Using the DOM based extensions will take up significantly more memory as the raw XML is because the XML will be parsed completely into a tree structure of nodes. Have a look at XMLReader instead
The XMLReader extension is an XML Pull parser. The reader acts as a cursor going forward on the document stream and stopping at each node on the way.
and make sure you parse with LIBXML_PARSEHUGE
An alternative would the event-based XMLParser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With