How to Increase PHP Memory Limit

The PHP memory is the maximum memory (RAM) your site can operate at one time. Most hosts have set the PHP memory limit to a small amount (e.g., 128MB), but you can increase it to a large amount with the following steps:

Step 1: Login your hosting account (e.g., Hostgator Hosting);

Step 2: Click "File and Folder" tab from the ribbon;

Step 3: Click "Open File Manager";

Step 4: In the "File Manager" window, click "wp-config.php", then click "Edit" from the Ribbon;

Step 5: Copy the following codes to the file just before "/* That's all, stop editing! Happy blogging. */". You can change "512M" to any amount.

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

Step 6: Click "Save changes" button on the top right after finishing everything.

If you have a different hosting, the path will be different, but once you find the "wp-config.php" file, you can easily increase the PHP memory limit.

If you do not want to go through your hosting site, you can use FTP server "Filezilla" to find your "wp-config.php" file.

What is the possible problem when the PHP memory limit is too small?

One common error you might get when you operate an operation with large memory is below:

Fatal error: Allowed memory size of xxxxxxx bytes exhausted (tried to allocate xxxxxxx bytes) in /home2/xxx/public_html/wp-content/index.php on line xxx

The error might be slightly different from one another, but the error should be resolved once you increased the PHP memory limit.

When can you get this fatal error?

In theory, anytime you try an operation which exceeds the PHP memory limit, you will have this error. For example, if you change the number of items per page from 20 to 900, you might get this error.

Leave a Reply