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.
Related: How to increase PHP memory limit
Steps to change PHP memory limit in cPanel:
- Log in to your cPanel account.
- Open Select PHP Version under the Software section.
- Click the Options tab at the top.
- Find the memory_limit option in the list and click on the dropdown icon.
- Choose the desired memory limit value from the list.
If the desired memory limit is not listed, contact your hosting provider for further assistance.
- Confirm the change and wait for it to take effect automatically.
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.