Need help? Chat now!
Search results for:
Table of Contents
Note: This article is for Hostwinds clients who have access to WHM on their VPS, Cloud, or Dedicated Server.
Memory size errors commonly occur on a site built with open source CMS systems like WordPress, Joomla, Drupal, and Moodle. While there may be other factors, the primary cause is that the PHP's default memory limit setting isn't allowing enough memory to run or load the request.
The most efficient way to fix this is to increase the memory limit that PHP allows to process. However, if you cannot change the memory on your plan, you may fix the error using the steps provided below.
A note for shared hosting services and Hostwinds clients using WordPress: The wp-config file may be limiting the amount of memory available, as it may be allocating less than what PHP is allocating. You can increase the amount of memory WordPress allows in this file, but the amount in the php.ini file will determine the maximum amount allowed.
If you are comfortable with PHP, it is possible to increase the memory limit programmatically in your code. You will give PHP extra memory if a piece of code gets called instead of a sitewide increase for every PHP process.
ini_set('memory_limit', '1024M'); // or you could use 1G
If the error is fixed by increasing the memory limit and your code now works, you need to continue onwards and decrease the memory usage of your site further. Below are recommended steps that you can take. Note that while you don't have to do all of them, it will always help you to future-proof your site:
In addition, make sure PHP applications have enough memory allocated to them. If it is too low, it will cause a fatal error.
Alternatively, here are the steps you can take to increase the memory limit. Please note that if you are on a Shared Hosting Plan, you will need to upgrade your service to do so.
Step 1: Log in to WHM for the server you are going to upgrade. Note that you can find details to log into your WHM in the welcome email received upon purchase.
Step 2: Go to the PHP configuration editor.
Step 3: Edit the "memory_limit" variable to the size that you wish.
Step 4: Save your changes.
While this may help for a while, the errors are likely to return. If you're getting this error, there's a high probability that your code needs to be trimmed and optimized.
Note for shared hosting services and Hostwinds clients using WordPress: The wp-config file may be limiting the amount of memory available, as it may be delivering less than what PHP is allocating. You can increase the amount of memory WordPress allows in this file, but the amount in the php.ini file will determine the maximum amount allowed.
Example: If PHP only allows 128MB and you change the wp-config file to allow 512MB, you will only get 128MB. But PHP might be allowing more than the wp-config file, so increasing the amount in the wp-config could help if that is the case. If you have upgraded your account to a VPS or Dedicated Server, you can control this setting fully.
Written by Hostwinds Team / December 13, 2016