> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resolving the 'Allowed memory size exhausted' PHP error message

> Fix the 'Allowed memory size exhausted' error in PHP for web apps like WordPress or Drupal.

This article describes how to resolve a problem that may occur when you run a PHP-based web application, such as WordPress or Drupal.

## Problem

When you try to view a PHP-enabled page, you receive an error message that resembles the following (the exact values and paths vary):

```
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 33554432 bytes) in /home/example/public_html/filename.php on line 1622
```

## Cause

This problem occurs when an application uses more memory than PHP allows.

## Resolution

If you develop a site using your own PHP code, you can try to make your code more memory-efficient. For example, you can use the [unset() function](https://secure.php.net/manual/en/function.unset.php) to destroy variables and objects that you no longer need, thereby freeing up memory.

However, if you are running a third-party web application, such as WordPress or Joomla, it is highly inadvisable to modify the code directly. In such scenarios, you may need to increase the PHP script memory limit. The method to do this depends on the type of hosting account you have.

<Warning>
  **Important**

  To determine which of the following methods applies to your account, please see [this article](/docs/changing-php-settings-and-versions).
</Warning>

* If your account uses *php.ini* files to change PHP settings, for information about how to change the script memory limit, please see [this article](/docs/php-script-memory-limit)

* If your account uses *.htaccess* files to change PHP settings, for information about how to change the script memory limit, please see [this article](/docs/setting-the-php-script-memory-limit-in-an-htaccess-file).

* If your account uses CageFS, follow these steps:

  1. Log in to cPanel.
     > 📘 Note
     >
     > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

  2. In the **Software/Services** section of the cPanel home screen, click **Select PHP Version**:\
     ![cPanel - Select PHPVersion icon](https://static.hosting.com/kb/kb-turbo-php-version-icon.png)

  3. Click **Switch to PHP Settings**.

  4. Locate the **memory\_limit** row, select the new value for the script memory limit, and then click **Apply**.

  5. Click **Save** to save the settings. The new PHP setting takes effect immediately.

## Related articles

* [Changing the PHP memory limit for scripts](/docs/php-script-memory-limit)

* [Setting the PHP script memory limit in an .htaccess file](/docs/setting-the-php-script-memory-limit-in-an-htaccess-file)
