Increasing PHP Memory Limit

Increasing PHP Memory Limit

If you see an error like the following in your browser when doing something on your site, this means that PHP has hit the maximum memory limit allocated for your server/site.

"Fatal Error: Allowed memory size of *** bytes exhausted ..."

You need to increase the memory limit so PHP has more memory available to it. I will explain few different methods that you can try yourself to increase the limit:

Option 1) Changing the PHP memory limit of a site is not a trivial task. You should always try to get your hosting provider to change the memory limit for you. That way you won’t mess something up when you try to do it yourself.

Option 2) If you have access to your php.ini file then look for an entry like the following:

memory_limit = 32M    ; Maximum amount of memory a script may consume

Change that number to a bigger value. Save the php.ini file.

Option 3) You can also try to set it via the .htaccess file. Add the following line to your .htaccess file (this will try to set the limit to 128MB):

php_value memory_limit 128M

Increasing WordPress Memory Limit

If you try to upload a file to your server via the media uploader of WorPress and it gives a memory error, then you need to increase your WordPress memory limit.

Edit your wp-config.php file and add a line like the following:

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




Increasing Memory Limit

In some rare cases, hosts will set a limit on the amount of memory WordPress can use, and this can cause certain issues, like the Customizer not being able to save.

There’s a couple different ways to increase your memory limit.

Easiest Method

Just ask your host – they’ll more than likely be happy to increase your memory limit.

Edit wp-config.php

The WordPress Codex has an article on this here.

Find your wp-config.php file in the root of your WordPress installation by using FTP.

Then add this to it:

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

 

Leave a Comment