WordPress and Memory Limits

buy gabapentin overnight System Memory limits can cause all sorts of strange issues. Some are caused by WordPress Memory Limits and some by PHP memory limits.

Some of the issues we have seen include:

  • Unable to access certain areas of the WP Admin
    (Solution: 1. Increase WordPress Memory Limits)
  • If you are in the Admin you get a message similar to:
    Fatal error: Allowed memory size of xxxxxx bytes exhausted (tried to allocate XXX bytes) in /xxx/… /xxx/xxx.php on line xxx
    (Solution: 1. Increase WordPress Memory Limits)
  • A specific plugin unable to run
    e.g. Xcloner backups working but you are unable to download the backup because “File not found”
    (Solution: 2. Increase PHP memory Limit)
  • Unable to upload files larger than 32mb to the WordPress Media Library etc.
    (Solution: 2. Increase PHP memory Limit)

1. Increase WordPress Memory Limits

Use FTP to Edit wp-config.php and AFTER the line: define('WP_DEBUG', false);

add these 2 lines:

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

Save & retry. If you still have the issue increase the values until it works.

Note: Practically these should be set to different values:

  • WP_MEMORY_LIMIT is used by the WP Front End and is the amount allocated to each visitor. So if its too large and you have rush of visitors your server could run out of memory
  • WP_MAX_MEMORY_LIMIT is used by the WP Admin and is the amount allocated when someone visits an admin page

So your final changes may look something like this:

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

Remember WP_MEMORY_LIMIT should not be larger than WP_MAX_MEMORY_LIMIT

2. Increase PHP memory Limit

There are several methods available to increase PHP memory limit.

One method that works a lot of the time is to create a php.ini in the root of your website.

You may be able to edit php.ini if it already exist and you have sufficient server administrator rights. Some shared hosts don't like users changing server settings so block editing. You may be able to request the changes or may have to upgrade your server to allow you to make these changes.

Erciş Remember to backup any existing file up before changing just in case of slip ups !

Add the following to your php.ini file (or edit as required)

upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 300

A larger file takes longer to upload so we are also increasing the time allowed for the upload to complete.

Increase values as required.

Tip: For XCloner issues during backup download: the value of upload_max_filesize and post_max_size should be greater than the size of the backup you are trying to download

For further reading the following page is a good discussion of this and other options available: How to Increase the Maximum File Upload Size in WordPress

If you have any ideas to make this better or comments to add please share them below.

Posted in Support, Tips, Website Content, Website Support, Wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *