Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix the "Allowed memory size exhausted" Error

This guide explains why PHP shows this error and gives you several ways to fix it.

Fixing Errors2 min read10 steps

What does the error mean?

The message looks like this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes)

PHP is the language that runs many websites, such as WordPress. Each PHP script gets a fixed amount of memory to work with. Memory is like the size of a desk. If the job needs more desk space than you have, PHP stops and shows this error.

The first number is your limit in bytes. The number 134217728 equals 128 MB. The second number is how much extra PHP asked for when it ran out.

Common causes

  • A heavy plugin or theme.
  • A big image or file being processed.
  • A large import or backup task.
  • A script with a bug that loops forever.
Warning: Take a backup before you edit any file. A small typo can break your site.

Fix 1: Raise the limit in php.ini

  1. Log in to your control panel.
  2. Open the PHP settings tool, such as MultiPHP INI Editor in cPanel.
  3. Find memory_limit.
  4. Change it to a higher value, such as 256M.
  5. Click Save and reload your site.

Fix 2: Use a .htaccess line

  1. Open the .htaccess file in your site's main folder.
  2. Add this line at the bottom:
php_value memory_limit 256M
  1. Save the file. If you now see a 500 error, remove the line. Your server may not allow this method.

Fix 3: For WordPress, edit wp-config.php

  1. Open wp-config.php in your site's main folder.
  2. Add this line above the text "That's all, stop editing":
define( 'WP_MEMORY_LIMIT', '256M' );

Still not working?

  • Turn off plugins one by one to find the heavy one.
  • Your plan may cap the memory limit. Ask Hostvento support what the maximum is. You can open a support ticket.

Quick recap

  • The error means PHP ran out of its memory allowance.
  • Raise memory_limit in the panel, .htaccess or wp-config.php.
  • Back up before editing files.
  • Find and remove any plugin that uses too much memory.
  • Contact support if your plan limits memory.