-2

I have a php script that I run from ubuntu command line to read a huge xml file and insert it into a mysql db.

I tried the script on a small file and it works without problem.

php -f parse.php

The problem is when i tried to run it on the big xml file the script returns almost immediatly with the return :

Killed

Anyone have any suggestion how to run the script, or how to find what's the problem ?

  • maybe this can help you http://stackoverflow.com/questions/20520194/php-script-is-killed-without-explanation – catalinetu Jul 31 '14 at 16:14
  • Are you Using SimpleXML or XMLReader to read the XML file? – Mark Baker Jul 31 '14 at 16:15
  • Killed is the out of memory process running. try splitting the file or getting more ram – exussum Jul 31 '14 at 16:16
  • Please post some code, or a peek at the server error log or both. Without those we're just guessing. –  Jul 31 '14 at 16:17
  • I'm using SimpleXML, is XMLReader more performant ? – user3815759 Jul 31 '14 at 16:45
  • SimpleXML loads the entire file into memory before allowing you to process it: XMLReader is a [pull parser](http://en.wikipedia.org/wiki/XML#Pull_parsing) reading into memory only the current element that is being iterated over, so it is far more memory efficient – Mark Baker Jul 31 '14 at 21:09

1 Answers1

0

You've exhausted the memory. You'll need to split up the xml file into more manageable pieces. You can also try running it on a machine with more ram.