How to Fix Memory Exhausted Error in WordPress

The fairly memory exhausted error can be a real headache. The task you were trying to complete most likely won’t work till you have fixed the error. Luckily, this article discusses just how you can fix that on your WordPress site.

Why am I Seeing the WordPress Memory Exhausted Error?

WordPress was coded in PHP, a server-side programming language (Fun fact, PHP is short for PHP: Hypertext Preprocessor. They call it a recursive acronym). For a WordPress website to work well, it needs to run on a WordPress hosting service that serves the files necessary for the site to work.

Web servers are a class of computers even though they’ve been built to serve web pages. They have storage and processors, and they have a memory that they use to run more than one program at once. Server admins get to set how much of this memory each application can use. PHP is also subject to this memory allocation.

The Memory Exhausted Error is raised when the PHP code on your website needs more memory to run than the server has available at the time. The error looks like this:

‘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’

Most commonly, I have run into this situation in times when I tried to import a theme’s demo files and assets. Most themes’ demo data pages will even try to analyze your PHP limits and suggest if it’s too low for the importation process to complete successfully.

WordPress tries to increase the PHP limit if it’s less than 64MB on installation. Even that adjusted limit is not enough sometimes, though. You might still need to increase the memory limit after this adjustment if you want to avoid the Memory Exhausted error since it’s more of a guideline for required memory than a requirement set in stone. 

The more demanding your tasks are going to be on your website, the larger you should make your PHP memory. An eCommerce store needs a lot more memory for its carts, shipping, and payment systems than a portfolio site would need for its relatively simple functionality, for example.

Steps To Increase PHP Memory Limit in WordPress

You need to find and edit your wp-config.php file on your WordPress site. You’ll either need to use an FTP client or the file manager that your hosting provider may have available.

When you have the file open, Copy this line of code:

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

Paste that in the wp-config.php file close to the end, before the line that says to stop editing. That line of PHP code asks WordPress to let PHP have up to 256MB of memory.

Now, save the file and upload it back to your server if you used the FTP method. Reload your site and the WordPress memory allocation error should be gone.

That was simple enough, but there’s a chance that it fails. In that case, your hosting service provider has a restriction on WordPress that doesn’t let it increase the memory limit, in which case you’ll need to ask the service provider to increase it manually.

How to Avoid PHP Resource Limitations

The memory exhausted error is just one of the PHP limitations that could be imposed on your site as a result of the type of hosting you use. Other variables like PHP time limit could also cause tasks on your site to bug out during tasks like cron jobs and time-sensitive applications.

If your site has a lot of functionality (and thus uses a lot of memory), you may want to consider VPS or dedicated cloud hosting instead of shared hosting. Memory limitations are one of the ways hosting providers regulate server resource usage since several websites are on a single server. With VPS or cloud hosting, you have more memory to work with, and the resources provided to you scale proportionally as your site grows.

Hopefully, this article helped you clear up the memory exhausted error you were facing on your site by increasing the PHP memory limit.

 

Have questions or confused about something WordPress Related? Join Our Discord Server & ask a Question

Leave a Comment

Your email address will not be published.

Scroll to Top