In: teach yourself
18 Aug 2008
Recently i have encountered a problem on my WordPress administration panel doing some operations, especially on plugins (activation/deactivation/automatic update) or for example on the xml export function, the specific error received is:
PHP Fatal error: Allowed memory size of xx bytes exhausted (tried to allocate xx bytes) in /home/…/
Searching on Google i read the phenomenon isn’t so rare, that’s due to PHP scripts that uses more memory of that allowed set on the server.
With phpinfo() at line memory_limit i saw that in my hosting is set to 32M.
For the resolution of this problem if can be set directly on the configuration file of PHP (php.ini) a major memory amount with the directive php_value memory_limit xxM (where at place of XX enter the desidered value, 12, 16, 32, 64…), this operation requires the restart of web service. If the situation is same of mine that im in external hosting, you can follow these ways:
- if the web hosting provider support the .htaccess file, you can increase the memory size directly in this file (if doesn’t exists should be created and placed in the root of web space) with the directive php_value memory_limit xxM
- ff you are few skilled, on the specific php page that causes the error, place the instruction ini_set(”memory_limit”,”xxM”); (yes, it’s needed also the “; )” just after the tag < ? and before of all the rest
Moreover i found other tricks in these 2 interesting articles Improve Site Performance by Increasing PHP Memory for WordPress, WordPress Error Fix(?): Increase PHP Memory for cache.php:
- in the wp-config file set the directive @ini_set(“memory_limit”,”xxM”); just after < ?php>
- over set the htaccess as described above, create and upload a file called php.ini simply with the instruction memory_limit = xxM
However from second article the author has created a zip you can download, called PHP Memory Control Pack with ready files.
Finally to remember that these are tricks to “force” the normal use of WordPress and should be used only if needed, for the normal use with the actual WordPress version (2.8.x) should be sufficient the default settings, as it also affects performances.
If you want monitor the memory usage the are some specific plugins like WP-Memory-Usage and the more detailed WP System Health
No related posts.
Do you know an interesting news about free/opensource software, web apps and services, graphic and web design, computer tutorials etc...? Please contact me and submit it, if i find it interesting i will consider to publish it.
Go to Advertising page, you could be interested!
Do you know an interesting site about free/opensource software, web apps and services, graphic and web design? Please notify me by contact form and if i find it interesting i will consider to link in my articles.
2 Responses to How i solved the problem of PHP memory exausted on WordPress
errors php
September 9th, 2008
[...] php Fatal error: Allowed memory size of xx bytes exhausted tried to allocate xx bytes in /home/…/http://www.digitalking.it/2008/08/18/come-ho-risolto-il-problema-di-memoria-esaurita-php-su-wordpres…PHP: Error Handling Functions – ManualAffecting PHP’s Behaviour. Error Handling and Logging. [...]
Ottimizzare l’uso di memoria di Wordpress per le migliori performances | Simo Blog
July 6th, 2009
[...] Se tutto ciò non bastasse e non si rientra nei limiti è comunque possibile aumentare il livello di memoria (in base a quelli che il proprio hosting concede) come ho descritto in questo precedente articolo. [...]