Tag Archives: fix PHP memory issues

How To Adjust PHP Memory Limit For Better Website Performance?

People may need to set or increase the amount of memory PHP scripts can consume in various situations. Running complex applications like WordPress, Magento, Joomla, or Drupal often requires higher memory limits because these platforms handle multiple functions, plugins, and themes. This increased demand can quickly exceed default limits, leading to errors or incomplete processes.

Common Errors Due To Low PHP Memory

When PHP memory is low, various errors can arise, affecting website functionality. A common error is the “Allowed memory size exhausted” message, indicating that a script needs more memory than the allocated limit. This can cause pages to load partially or fail altogether, resulting in broken forms, incomplete image uploads, or failed processing of large files.

Low memory also often leads to “500 Internal Server Error” messages, as insufficient memory prevents scripts from running properly. Complex plugins or themes, especially on WordPress, may stop working or create blank pages due to memory constraints. Increasing the memory limit can resolve these issues, ensuring smoother site performance and fewer interruptions.

PHP memory error often occurs when:

  • A large script or complex function runs.
  • A low PHP memory limit is set on the server.
  • A website has too many active plugins or heavy themes.
  • Server settings have insufficient memory allocation by default.

To set the maximum amount of memory that PHP scripts can consume, you’ll need to adjust the memory_limit setting in the MultiPHP INI Editor in cPanel. Here’s how:

To quick fix a PHP memory error via cPanel:

  1. Login to cPanel – Use your credentials to access your cPanel dashboard.
  2. Locate the “MultiPHP INI Editor” – This tool allows you to modify PHP configuration.
  3. Select Your Domain – Choose the domain where the error occurs.
  4. Adjust PHP Memory Limit – Find the memory_limit setting and increase the value (e.g., 256M or 512M).
  5. Save Changes – Click “Apply” or “Save” to update the configuration.

Now check if the error is resolved. Simply refresh your website to confirm the issue is fixed.

The Step-By-Step Guide To Adjust PHP Memory Limit:

Step-1 Log in to cPanel: Access your cPanel.

Step-2 Open MultiPHP INI Editor: Scroll down to the Software section and click on MultiPHP INI Editor.

Step-3 Choose a Location: You’ll see two options to configure PHP settings:

  • Basic Mode: Provides a user-friendly interface to select the PHP directives.
  • Editor Mode: Lets you directly edit the php.ini file for finer control.

For most users, Basic Mode is easier to work with.

Step-4 Select the Domain: From the drop-down menu, select the domain or location you want to apply the memory limit change to.

Step-5 Find the memory_limit Setting: In the list of settings, locate the memory_limit option.

Step-6 Adjust the Memory Limit: Enter your desired memory limit in MB. For example: 128M (128 megabytes), 256M, or even 512M for resource-intensive applications.

Be sure to enter a value within the limits allowed by your hosting provider.

Step-7 Save Changes: Click Apply or Save at the bottom of the page to confirm the new memory limit.

When You Need To Adjust The PHP Memory Usage?

Uploading large files is another common reason for adjusting memory. When users upload bigger files, such as images or videos, PHP scripts use more memory to process these uploads. If the limit is too low, uploads may fail or time out, resulting in a poor user experience.

For data-intensive scripts, like those managing extensive database queries, complex arrays, or calculations, having enough memory is crucial. Large data sets or intensive processes need more memory to run smoothly; otherwise, they can cause errors or stall during execution.

People may also notice “out of memory” errors appearing in logs or on their sites during specific tasks. Increasing the memory limit helps prevent these issues, ensuring the site functions reliably.

Image and video processing is a common feature on many websites, especially for media-heavy applications. Resizing, cropping, or editing media requires significant memory resources, so sites that handle many images or videos need higher limits to process them efficiently.

Lastly, improving site performance and stability is often a motivation for setting a higher memory limit. If a site experiences lags during peak traffic or intensive tasks, increasing the PHP memory can help manage this load, offering a smoother experience for users.