PHP allocates a default amount of memory when executing scripts. If the script uses more memory than allocated, PHP throws a fatal error and stops execution. This happens when the script exceeds the memory limit, and it’s common with resource-intensive applications.

PHP Fatal error: Allowed memory size of xxxx bytes exhausted (tried to allocate yyyy) in yourscript.php

You can prevent PHP from consuming excessive memory by keeping the default limit. However, for scripts that need more memory, you may need to increase the PHP memory limit to ensure they run without interruption. Adjusting the memory limit is necessary for handling larger data sets or more complex processes.

In cPanel, the PHP memory limit can be changed through the dashboard. This is done by configuring the memory_limit option within the PHP settings. Increasing this limit provides the necessary memory for demanding scripts and helps avoid memory exhaustion errors.

Steps to change PHP memory limit in cPanel:

  1. Log in to your cPanel account.
  2. Open Select PHP Version under the Software section.
  3. Click the Options tab at the top.
  4. Find the memory_limit option in the list and click on the dropdown icon.
  5. Choose the desired memory limit value from the list.

    If the desired memory limit is not listed, contact your hosting provider for further assistance.

  6. Confirm the change and wait for it to take effect automatically.
Discuss the article:

Comment anonymously. Login not required.