The "memory_limit" parameter appears in php.ini. On my CentOS servers, the default is 128M.
If PHP exhausts memory you'll see an entry in /var/log/apache2/error_log unless you let the application write errors to the browser page. I've run out of memory in PHP because of an endless loop in a for() structure that creates an array:
Code:
$n=0;
$my_array=array();
for ($i=0; $i<999; $i++) {
$my_array[$n]=$n;
$n++;
$i--;
}
That will create an infinitely sized array and exhaust memory in PHP. You can monitor the memory by adding
Code:
* * * * * root /usr/bin/free | grep Mem: >> /var/log/memory.log
to /etc/crontab. That will write a memory usage snapshot every minute to memory.log.
I'd also install smartmontools and use "sudo smartctl /dev/sda" to check the "SMART" status of the hard drive. You might also re-seat the memory chips if you haven't done so in a while. Sometimes problems like these happen intermittently because of heat buildup.
Bookmarks