Hi,
I'm doing some parsing of poker hand history files and made a system that is working well but with one major exception.
When the files are larger than somewhere around 100k the script will die before it reaches the end of the file.
If I use firefox it starts outputting and it takes about 4 seconds and then I get a "connection reset" page.
In IE it takes a couple of seconds and I get a "page not available".
The script reads a local file as input and I read hand by hand using file_get_contents($filename, FALSE, NULL, $offset, $end)
That input is then processed using a state machine which goes through an array with states containing different preg statements to extract the information from the input. Each hand is in the region of 30 lines.
It stores the data in an array and when the hand is finished parsing it saves it into an MySQL database and I clear the array and start processing the next hand.
I tried the script locally using a default xampp install on XP as well on my linux host with same results.
When I use Charles debugging proxy the page does not get replaced with the connection reset page and I can follow the output of the script all the way until it quits.
The scrip uses about 5Mb before it dies according to memory_get_usage, and upping memory limit or execution times have no effect.
I have tried with the following php.ini setting with no effect on how long the script will run:
pcre.backtrack_limit = 1000000
pcre.recursion_limit = 1000000
ignore_user_abort = On
max_execution_time = 120
max_input_time = -1
memory_limit = -1
pcre.recursion_limit sometimes crash apache at that extreme setting, but when it doesn't the script stops at the same place.
I have error reporting set to E_ALL but receive nothing in neither php or apache error logs.
It seems like there is some resource limitation since if I remove a few lines in the start of the file it will parse a few lines more, so the problem is not relating to a certain part of the code or the input.
Any ideas about if there is any resource settings that could fix the problem?
I'm not so keen on rewriting too much of the code, but if I at least had a clue what to look for in my code to find the culprit, but without knowing what resource is exhausted and no error messages to help me I really don't know where to start.
Any ideas greatly appreciated!