PHP memory limit errors in wordpress

In wordpress, you may face PHP memory limit error and encounter following error,

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxxxxx/public_html/wp-includes/plugin.php on line xxx

Such error is due to PHP Memory Limit set by the host, this value is set in server’s php.ini file . You  can overcome this issue by,

  • Increasing the limit via php.ini file

You can directly increase the PHP Memory Limit if you’ve access to the php.ini file. With some hosts, you may not have access to php.ini , in that case ask your host to copy php.ini file to your public_html folder or respective folder where wordpress is installed or you can create a file called php.ini. It can be set by editing value as

memory_limit = 64M

You can change the value as per your requirement.

  • Changing PHP memory limit in wp-config.php

If you don’t have access to php.ini file, alternative value can be set in wp-config.php. You need to edit wp-config.php and add following line after the <?php tag

define(‘WP_MEMORY_LIMIT’, ’64M’);

save the file and check.

  • Modification of the .htaccess file

This is alternative way, a very simple one.  You need to set proper value by editing .htaccess file as below.

php_value memory_limit 64M

  • Setting php memory value in install.php

This is yet another way to increase the PHP Memory Limit of your WordPress. There is an install.php file in the wp-admin folder of the WordPress installation.

All you should do is just add the command ini_set(‘memory_limit’,’64M’)in the install.php file. You will see the PHP Memory Limit increased.

  • Installing a wordpress plugin

If all above steps are not working, you can try installing proper wordpress plugin which monitors the memory usage or adds proper value in wp-config.php file (with 256MB limit) automatically and no need to edit the php file or set memory limit any where. Just install and activate it.

You can check the plugin here.

Tagged , . Bookmark the permalink.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.