How to increase memory limit in WordPress website?

Increase memory limit in WordPress website is not a simple method. The default memory limit in WordPress is 32 MB. It is normal to exceed this limit and get the error, Fatal error: Allowed memory size. The fatal error message show in below one:

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

How to easily increase memory limit in WordPress to avoid memory exhausted error.

There are two way to increase memory limit issues:
1. Increase by yourself
2. Contact your hosting provider company

Increase memory by editing wp-config.php file: Open wp-config.php file, which by default is placed in the root WordPress directory. Find the below line end of the file.

/* That's all, stop editing! Happy blogging. */

Above that line add the following line:

define('WP_MEMORY_LIMIT', '256M');

Above code say WordPress to increase the PHP memory limit to 256MB. After you are done, you need to save and upload wp-config.php file to the server. Now refresh your WordPress site to see the error goes away.

Increase memory by editing php.ini file: If you have rights to access your PHP.ini file, then change the line in php.ini. If you have rights to access your PHP.ini file, then change the line in php.ini memory_limit 64M try 256M. See below example:

memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)

Increase memory by editing .htaccess file: You can also increase your WordPress memory limit with your .htaccess file. It is placed in your root directory. Add the below code to it, or edit the line still there if you find it:

php_value memory_limit 256M

Save .htaccess file, and upload it to your root directory (/home4/xxx/public_html/), overwriting the original file. Refresh your WordPress site to see the error goes away.

See our article on .htaccess file optimize website.

Many hosts provider limit the amount of memory your server is allowed to use, especially shared hosts. Many shared hosting providers don’t give you access to your php.ini file, so if you’re having trouble to fixing an error please contact hosting provider.

1 thought on “How to increase memory limit in WordPress website?”

Leave a Comment