Reputation: 73
I've assigned the memory limit of php to 999m so it appears in phpinfo like
memory_limit 999M 999M
when I use phpinfo(); to show it.
Unfortunately when I try to run a fairly large script, it seems like the limit is 256M
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 40 bytes) in /xxx/wp-includes/wp-db.php on line 1403
Anyone have any ideas why or what I can do to increase the limit (and have it actually work)
If it helps I'm running centos5 32bit and with php running in fcgi mode
Upvotes: 3
Views: 27801
Reputation: 930
I installed php74 with macports. When I ran php --ini it was showing that my ini files are in '/opt/local/etc/php74' directory. There was two files: php.ini-development & php.ini-production. I changed memory_limit on these files but still there was no effect.
Then I created a new file 'php.ini' in the same directory and changed the limit on that file. Then the effect took place. When I ran php -i | grep "memory_limit" I could see the updated value.
Upvotes: 0
Reputation: 635
Type php --ini
to find the configuration paths.
Change memory_limit
to whatever value you need.
Make sure that you are changing it on both these files: php.ini
and conf.d/php-memory-limits.ini
(in my case, I use -1 to have unlimited memory (of course, not unlimited but as much as my computer can handle))
Upvotes: 5
Reputation: 3783
Make sure you server/virtual server in apache is not configured to overwrite PHP configuration. Even if you use:
php_value memory_limit 512M
Your server may have something like:
php_value memory_limit 32M
which will make your changes in php.ini useless. To fix this:
Upvotes: 0
Reputation: 410
I had a similar issue, for me it was an extra ini file that was loaded called "99-liip-developer.ini". At the top of the file the memory_limit was defined at 265M, which overwrote the memory_limit defined in php.ini.
Hope this helps anyone.
Upvotes: 14
Reputation: 10329
Create a php file called test.php, put inside:
<?php
phpinfo();
?>
Check for "Configuration File (php.ini) Path" and "Loaded Configuration File" to see the correct php.ini path. Edit php.ini and search for memory_limit and set it to:
memory_limit = 999M
Check if you have more than one occurrency of memory_limit into the php.ini file. In the case, delete it.
Stop apache, and then restart it (apachectl restart | apachectl graceful | kill -1 are not ok. Stop, then start).
Recheck test.php to see if the new parameter got acquired.
Upvotes: 0
Reputation: 3535
Unsure, but this came up in the google search for me:
The ping optimizer was cramming a table full on the DB and clearing solved the problem. The error was almost the same:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 80 bytes) in /home/user1/public_html/domain/wp-includes/wp-db.php on line 1400
So see if a plugin is doing the same, then clear it and log it on WP somewhere so it can be fixed if that is the problem.
Upvotes: 0
Reputation: 8301
You can try putting this at the top of your file
ini_set('memory_limit', '999M')
How much system memory do you have available? Did you restart Apache after editing your php.ini file (I assume you have php installed as a module)?
Try:
sudo /etc/init.d/httpd restart
Upvotes: 0
Reputation: 997
I suggest you set this on the top of your script:
ini_set("memory_limit","512M");
in the script that is consuming so much of your memory instead of allowing all scripts to consume so much memory. You can also put this in the .htaccess of your /wp-includes/
php_value memory_limit 512M
More information and explanation here: http://www.mydigitallife.info/php-allowed-memory-size-exchausted-fatal-error/
Upvotes: 2