What is PHP memory limit?
PHP memory limit is the maximum amount of memory that a PHP process can use each time a PHP script is run. When you install PHP, it has a default memory limit. Below are the default memory limits for different PHP versions:
Before PHP version 5.2
PHP version 5.2
Later than PHP version 5.2
If your PHP installation has a memory limit of 128MB, every time a PHP process runs, it is only allowed to consume up to 128MB of RAM (random-access memory) space. If the process reaches or attempts to exceed that limit, it will fail and return a PHP: Fatal Error which may result in HTTP 500 - Internal Server error.
If you want to know more about 500 Internal Server Errors, click the link below:
If you want to know more about PHP: Fatal Error, read the details below.
What is a PHP: Fatal Error?
When you use any CMS (content management software) such as WordPress, Moodle, Joomla, or Drupal in running your website, every time it runs, it will consume a part of your server’s memory or RAM. Sometimes, these frameworks can consume more than the memory limit set in your PHP installation. When this happens, you will get a PHP: Fatal Error, which will look similar to this:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2515174 bytes)
in (file path) on line (0).
This example shows that the memory limit (32MB) has been reached and when an additional 2.4MB is requested to be allocated, PHP fails with a fatal error. You can fix this particular error by increasing the memory limit in your php.ini file.
If you don’t have a php.ini file yet and want to know how to create one, click the link below:
By default, your site will use the standard PHP settings on your server. However, if you need to revise or change any of the default PHP settings on your server, you can do so by creating and/or modifying a php.ini file.
How to increase the PHP memory limit
As mentioned, you can fix a PHP: Fatal Error by increasing the PHP memory limit in your php.ini file.
To do this, follow the steps below:
- Click on My Account at the top of the page.
- Select Hosting Manager from the drop-down menu.
- Enter your username and password, and click Log In.
- On the Home page, click the word Files or the [ v ] arrow symbol on the right side.
- Click the File Manager icon, which is next to the Directory Privacy icon.
- On the pop-up screen, select Web Root (public_html/www) and click Go.
- On the next screen, all of the files and folders in your web space will be displayed in a tree-style directory.
Look for the php.ini file in your public_html folder.
- Right-click on the file and click Code Edit.
- Using the Code Editor, within the php.ini file, search for the following text:
max_execution_time = 30
Increase the size of the memory_limit. The size is usually in megabytes.
max_input_time = 60
memory_limit = 128M
- Click Save Changes.
- Reload/refresh your site and test if the increase in memory_limit is enough.
If it isn’t, it is recommended that you increase the memory_limit value again until you find the size that will resolve the memory-related Fatal Error.
Important Note: In order for your php.ini updates to take effect in all your child folders, you have to make php.ini recursive.
To learn how to make php.ini recursive, click the following guide:
Congratulations, you now know how to increase the PHP memory limit.
Important Note: To make sure that your server runs efficiently, do NOT set a PHP memory limit value that is more than 60% of the size of your server's RAM.
Moreover, it is NOT recommended that you set the memory limit to -1 (unlimited) because it will cause your "page load time" to lag.
If you want to know how to access the File Manager, click here.
If you want to know how to edit web files directly in File Manager, click here.
If you want to know how to change PHP versions, click here.
Fantastic...Thank you for your feedback =)
Sorry... Please submit a support ticket or try another search.