Morteza M. Morteza M. - 2 years ago 134
PHP Question

Another PHP out of memory problem using apache

I know it is an old question! But this time I have different situation.

I'm running php/mysql/apache on OpenSuse. I have set php with 128MB of memory. I don't have any

for apache.

Everything was fine, birds singing, flowers blossoming but once I restarted my apache then bad things happened!

I get
PHP Fatal error: out of memory blah blah
. All php powered applications that were working fine, now log this error. What happened? I tried memory_limit = 512M without any progress.

I'm confused why all my php files now throw this error except really small scripts. I tried phpinfo() and I really have 128MB of memory there. ( And I know that php apache ini setting is different from standalone php, I configured the correct one! ).


exact php error samples:

[Mon Jul 25 04:22:25 2011] [error] [client] PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 491520 bytes) in /srv/www/htdocs/phpMyAdmin/libraries/ on line 796

[Mon Jul 25 04:26:39 2011] [error] [client] PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 4 bytes) in /srv/sbuta/library/Zend/Config/Ini.php on line 172

[Mon Jul 25 04:27:02 2011] [error] [client] PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 30720 bytes) in /srv/kode/library/Zend/Config/Ini.php on line 132

Answer Source

The problem is that there is no remaining physical memory! disabling some php or apache modules should fix the problem.

Step by step guide(:D) :

  • See if you have assigned php enough memory to use. usually at /etc/php5/apache2/php.ini search for memory_limit = ... . ( to test it, try putting a file with some strange name in your server with this content: <?php echo phpinfo();?> and see memory_limit value there ).
  • Test if you have any RLimitMEM in your apache settings. you can use cd /etc/apache2/ && grep -irn 'RLimitMEM' to find out.
  • See if you have any security limits for wwwrun ( or what ever user apache is running with ) in /etc/security/limits.conf
  • Try to exclude some unnecessary modules from php and/or apache.

Remember to restart apache after any change to test it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download