2

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 RLimitMEM 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! ).

UPDATE:

exact php error samples:

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

[Mon Jul 25 04:26:39 2011] [error] [client 31.57.122.252] 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 31.57.122.252] PHP Fatal error: Out of memory (allocated 1048576) (tried to allocate 30720 bytes) in /srv/kode/library/Zend/Config/Ini.php on line 132

11
  • Remember to restart Apache after changing any config files too. Commented Jul 24, 2011 at 20:11
  • Look in your RCS's commit log. Find the change that broke everything. Revert it. Commented Jul 24, 2011 at 20:13
  • @mike thank you for your advice. I always do that. Commented Jul 24, 2011 at 20:19
  • @Tomalak Geret'kal, to be honest, I don't know how to do that!! I originally work with ubuntu. I'm not familiar with opensuse. Commented Jul 24, 2011 at 20:20
  • Make sure, nothing within the application changed the settings. Commented Jul 25, 2011 at 13:45

4 Answers 4

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thx. RLimitMEM helped me, found in /etc/httpd/conf/httpd.conf
0

Out of memory errors are the result of too much data stored in memory by your script. If you have a database with large data sets and pull data with fetchAll() instead of filtering you may run out of memory real quick. Another problem are objects where you store such large data sets. Last but not least you may have a loop that adds data to memory until it reaches the limit.

Check you scripts for places where you pull data and use XDebug. It can show you the increase on memory usage.

Update
Weird. The "out of memory" error you have here is not the error you usual get with the php memory_limit config (that has "memory exhausted") and since you have it with all apps this is even more clear.

There seems to be a limit imposed from the server environment which in your case is Apache. Maybe you can/must in fact set a max limit with RLimitMEM in your conf file. The default is to use the operating systems default which is your OpenSuse. If you suddenly have limitations for the user running your Apache module this may go to your Apache environment and then all the way to your PHP scripts which is finally complaining.

2nd Update
Time to isolate the problem. Because it began when you restarted your server and all your apps are experiencing this problem it has to be something in your server environment. Try to start and run phpMyAdmin with a default Apache config. If that already causes the error you have to look at your linux server.

6 Comments

I have this problem with all my web sites now! not any specific script. even phpmyadmin throws this error. and I used XDebug. my web app needs only 14MB.
Well then, can you update your question by adding the exact error messages. blah blah does not really help to identify the source of your problem. While we are at it maybe also XDebug trace from the same problem.
I'm sure it is not a memory leak. because if it was, just one domain went into this situation not all of them.
I tried RLimitMEM = 9999999999999999 without success. still the same errors.
thank you for your advice. But I found the source of problem. It was physical memory related. Updated question!
|
0

PHP restarts its scripts for each reload; unless you script runs 24/7, it doesn’t get affected by continue uptime of Apache. When Apache’s memory usage grows, it either has more PHP processes or it just started to leak memory like normal with Apache and PHP.

Given you have an array that has 100000000 elements containing "foo" and you pass them to another function, that function call copies that array, effectively doubling PHP memory usage. By getting few calls like this, you can easily get a situation where your script is out of memory.

Comments

0

I had this issue on one of my servers and it turned out to be a problem with the Gnome3 desktop environment. On Debian and Ubuntu servers with 2 Gigs of memory or less, if you have the Gnome3 or Unity desktop environment installed, it eats up so much desktop memory that it starts using up RAM that apache needs which leads to the out of memory error.

Resolve the issue by installing either the "Gnome-Classic", Mate or LXDE desktop environment and logging into that instead.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.