I recently ported a 2500 line script from Python to PHP. The script reads in 40,000+ records from a disk file and the comparable records from a database via a socket connnection, compares the two and updates the database with any changes.
Under Python there were no memory issues. With PHP, without memory limits imposed, the script chews up all 256MB of regular memory and starts in on the swap space. If I impose a memory limit, the script runs up to the limit and aborts.
The only way to get this script to run in under 64MB of memory is to "unset" every variable at the beginning of the main while loop. It still climbs from just under 3MB when it starts up to 55MB when it completes. If the input file gets any larger, I'll have to up the memory limit, I suppose.
Any comments on why PHP behaves this way? I would prefer to support a single language on the server and PHP is a comfortable choice. However, if I can't overcome this memory issue I guess I'll have to move on to Java or back to Python.
HELP!!
Scott