maybe you should try and break up your operation so that it can thread your requests... Like it runs for 10,000 records, then it submits itself to the same page, runs the next 10,000 records... some way to make php not retain all that stuff in memory and also to allow it to close any file pointers it may be using.
one other problem might be that the browser is timing out waitiing for responses, what are you printing to the screen during this proccess?
You might try writing your status to a log file instead of printing much to the screen and seeing if that log file continues to grow even after the browser side has "stopped responding"