WordPress ошибка out of memory

I’m getting this nasty error Fatal error: Out of memory (allocated 18087936) (tried to allocate 77824 bytes). Weird thing is, it’s 17,25 mb (allocated) and it tried to allocate 76 kb. Memory limit is 128MB, and as you can see it’s not even close to that. VPS got ~400mb of free ram at that moment. It only happens when I’m posting something and not all the time.
I find it weird and don’t really know what can cause it.
Let me know if you need any additional info.

asked Apr 13, 2013 at 20:45

Igor Yavych's user avatar

9

The error says that the memory limit is 18M and not 128M. This means that somewhere the memory_limit is set to something different than 128M (local php.ini, or the application itself, since PHP can override this setting at run-time).

I would suggest that you first create a file called (say) phpinfo.php with the following contents:

<?php
phpinfo();
?>

and place it where your script runs. Then access the file with your browser and look for the actual memory_limit value. If it’s still showing 128M both for «global» and «local» value, then probably somewhere in your code, there’s a «ini_set(«memory_limit», $value);» call or something similar. Otherwise, if it says 18M, look for other places where this can be set:

  • Check your wp-config.php file
  • Check for any local php.ini file (look into the phpinfo.php page to see the location of the actual loaded php.ini file)
  • Check for any .htaccess files that contain such a directive

answered Apr 14, 2013 at 12:08

periklis's user avatar

periklisperiklis

10.1k6 gold badges59 silver badges68 bronze badges

7

Hope this helps, as I had the same issue:

You’re running into a limitation in WordPress’s own memory limit, not your PHP memory_limit. WordPress implemented this limit in order to prevent poorly written scripts from shutting down your whole PHP interpreter. Unfortunately, as you’ve noticed, it’s rather barebones.

The easiest way I’ve found to fix this is to install the Change Memory Limit plugin from WordPress plugin repository. It allows you to fix the issue without modifying any WP files manually.

The 64M default for the plugin will probably be fine for you.

Alternatively, if you don’t want to trust a third party plugin, add the following line to wp-config.php:

define('WP_MEMORY_LIMIT', '64M');

answered Apr 22, 2013 at 10:05

Glitch Desire's user avatar

Glitch DesireGlitch Desire

14.5k7 gold badges42 silver badges55 bronze badges

4

Got it from this http://wordpress.org/support/topic/fatal-error-out-of-memory-messages?replies=24#post-1929111, thought I’d share it with you guys :


THIS TO BE ENTERED IN THE WP-CONFIG FILE WHICH IS IN THE ROOT OF THE WORDPRESS SETUP:
ENTER AFTER : 
define('ABSPATH', dirname(__FILE__).'/');
THE FOLLOWING:

define('WP_MEMORY_LIMIT', '64M');

ALSO CREATE A PHP.INI WHICH SHOULD BE UPLOADED TO THE PLUGIN FOLDER IN WP-CONTENT:

 `memory_limit = 128M; //Maximum amount of memory a script may consume (64MB)
`

max_execution_time = 45;


upload_max_filesize = 15M;


post_max_size = 30M;

Hope this helps!

answered Apr 22, 2013 at 10:06

Hiren Pandya's user avatar

Hiren PandyaHiren Pandya

9791 gold badge7 silver badges20 bronze badges

Just an option that helped me debugging these errors.

If you have access to the .htaccess, you could try this:

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
php_value max_input_time 300

If that doesn’t help, you could try this to check the settings:

echo 'Max upload size: ' . ini_get('upload_max_filesize') . '<br />';
echo 'Max post size: ' . ini_get('post_max_size') . '<br />';
echo 'Memory limit: ' . ini_get('memory_limit');

I hope this works, for me it did.

answered Apr 16, 2013 at 14:49

Ron van der Heijden's user avatar

I am not sure this causes the error, but it is worth checking for.

Many of the most untraceable pathetic out of memory errors are caused by :

1) User defined exception handlers, causing exceptions therefore recursing.

2) The above + trying to fetch class information of object originating the exception, and the class information testing causes an autoload attempt, in which autoload throws another exception and therefore recursing.

Have you done something conflicting with WP error handling or autoload?

answered Apr 17, 2013 at 12:15

Volkan's user avatar

VolkanVolkan

2,2121 gold badge14 silver badges14 bronze badges

I install wp-memory-usage plugin by alexrabe on all my WordPress sites.

This plugin helps you to see what WordPress is seeing in terms of your PHP memory usage. Other approaches may show you the PHP settings at the server, however these settings are often overridden with various techniques the closer you get to a rendered page within the browser.

To set your max memory -> open your favorite text editor and create a file called php.ini; include in the file the following line:

memory_limit = 256M

Place a copy of the php.ini your WordPress root directory. I also place copies in: /wp-admin; /wp-content; and /wp-includes.

answered Apr 18, 2013 at 13:59

TECH N's user avatar

Add define('WP_MEMORY_LIMIT', '256M'); in your wp-config.php file. Its the easiest way.

answered Apr 20, 2013 at 13:26

aakash's user avatar

aakashaakash

3761 gold badge5 silver badges18 bronze badges

1

It looks as through somewhere in the site, the memory limit is being overwritten, do a site wide search in the code for ini_set('memory_limit' and see what is returned.

answered Apr 21, 2013 at 3:12

duellsy's user avatar

duellsyduellsy

8,4572 gold badges35 silver badges60 bronze badges

1

Given that your phpinfo() script returns the correct value for memory usage, this is obviously being set in WordPress somewhere, and is therefore overriding the Apache provided values, so using a .htaccess to apply this still won’t work.
This link (http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP) suggests that WordPress does its own memory management by default, so setting the (‘WP_MEMORY_LIMIT’, ‘256M’) in the wp-config.php is logical.

If you have shell access to the server hosting your site I would suggest going to the DocumentRoot of your wordpress install and running the following commands:

grep -R "18M" *
grep -R -e '(WP_MAX_MEMORY_LIMIT|WP_MEMORY_LIMIT)' *

This will search through your files for the string 18M (the value your memory limit seems to be set to in human readable terms) and the configuration options for the WordPress defined memory limit. I suspect that one of these commands will return positive output. You should then change the WP_MEMORY_LIMIT as suggested (although 256M may be a little high — try 64M initially, you don’t want to cause yourself potential problems).

answered Apr 22, 2013 at 9:59

Chris's user avatar

ChrisChris

465 bronze badges

4

В произвольный момент времени любой разработчик, создающий тему или плагин, либо просто пользователь, работающий с WordPress, может столкнуться с ошибкой Fatal Error: Memory Exhausted (память исчерпана). Обычно эта ошибка выглядит следующим образом:

Fatal error: Allowed memory size is 268435456 bytes exhausted (tried to allocated 29596635 bytes) in …/wp-includes/wp-db.php on line 885.

Безусловно, ваше сообщение об ошибке может иметь несколько иной вид, однако смысл его одинаков: вы столкнулись с ошибкой, она имеет отношение к доступному объему памяти, вы знаете, какой именно объем памяти был затребован, а также какой файл вызвал ошибку.

По моему мнению, одна из самых заметных проблем с такими вот ошибками – это слишком быстрое нахождение решения в Google, ведь люди не стараются понять проблему.

Да, у нас под рукой всегда имеются материалы, которые прекрасно спасают в беде. Однако стоит помнить, что понимание проблемы помогает нам расширить свой багаж опыта, развивать и совершенствовать свой уровень.

В данной ситуации очень полезно разобраться с тем, почему возникла такая ошибка.

Содержание

  1. Ошибка нехватки памяти в WordPress
  2. Переводим байты в мегабайты
  3. Настройка PHP
  4. Увеличиваем лимит памяти
  5. Несколько слов о выделении памяти

Ошибка нехватки памяти в WordPress

Используя приведенное выше сообщение, мы можем сказать, что выделенный объем памяти составляет 268435456 байт. Однако кто сейчас считает в байтах?

Нам гораздо удобнее оперировать мегабайтами, гигабайтами и терабайтами (хотя если у вас такой объем памяти, и вы столкнулись с указанной ошибкой, то это – совсем другая история).

Переводим байты в мегабайты

Первое, что мы сделаем – это переведем байты в мегабайты. Сделать это можно, к примеру, с помощью Google — достаточно ввести в поисковую строку следующий текст:

268435456 bytes to megabytes

В итоге мы получим результат:

bytes_to_mb

Очень удобно. Но что нам делать с этой информацией?

Во-первых, мы должны понимать, что у нас есть предел в 256 Mb памяти, которая доступна для использования в WordPress и PHP, и этой памяти не хватает для совершения операций.

Честно говоря, ограничения нужно выставлять для PHP, однако я буду работать с WordPress, поскольку часть решения проблемы может включать в себя определение новой константы. Однако об этом – через одно мгновение.

Настройка PHP

Нужно понимать то, что PHP имеет лимит памяти, а также то, что вы можете в некотором роде управлять им через WordPress. Обычно есть две вещи, которые нужно сделать, чтобы убедиться в том, что проблема решена в полном объеме.

Но сначала надо узнать, какую именно версию PHP вы используете. Если вы работаете с PHP на локальной машине, то вы, скорее всего, сможете найти версию PHP в панели управления своего веб-сервера:

php_adjust

В противном случае версия должна отображаться где-либо в пределах панели управления вашего хостинг-аккаунта.

Это даст нам понять, какой конфигурационный файл PHP нужно редактировать. В частности, вам нужно найти файл php.ini, который связан с вашей версией PHP.

Если у вас установлена только одна версия, прекрасно; иначе вам нужно будет найти файл php.ini для вашей определенной версии PHP, которая в данный момент запущена.

Увеличиваем лимит памяти

Как только вы найдете файл php.ini, взгляните на директиву memory_limit.

php_memory

На скриншоте выше можно видеть, что лимит памяти установлен в 25 Mb, что явно меньше требуемого нам. Потому нам понадобится увеличить его до, скажем, 128 Mb, после чего перезапустить сервер.

Что делать, если WordPress по-прежнему жалуется на ошибку?

В данном случае вам, возможно, понадобится внести одно дополнительное изменение в файл wp-config.php. Есть две константы, которые мы можем определить:

  1. WP_MEMORY_LIMIT
  2. WP_MAX_MEMORY_LIMIT

Узнать подробнее про них можно в кодексе. Как показывает мой опыт, удобнее всего определить сразу две константы, чем одну WP_MEMORY_LIMIT.

Я упомянул это, потому что в сети ходят советы, согласно которым можно просто задать WP_MEMORY_LIMIT. Я не говорю, что это неправильно – просто у меня были наилучшие результаты, когда были определены обе константы.

По аналогии с php.ini, добавляем в wp-config.php следующие значения:

define('WP_MEMORY_LIMIT', '128M');
define('WP_MAX_MEMORY_LIMIT', '128M');

Это должно решить проблему.

Также можно задать следующее правило в .htaccess:

php_value memory_limit 256M

Несколько слов о выделении памяти

Хочу сказать еще пару слов о выделении памяти. Несмотря на то, что самое простое решение – это увеличить доступную память, его не обязательно нужно делать в самом начале.

Фактически, я прибегаю к нему уже под конец, когда ничего не помогает.

Зачастую эта проблема является результатом работы какого-либо фрагмента кода, процедуры или определенного алгоритма – все это можно усовершенствовать и оптимизировать.

Таким образом, обязательно проверьте ваш код – используйте различные инструменты отладки и тестирования, чтобы исключить неэффективные участки. Если таковых нет, то тогда уже можно прибегать к корректировке памяти.

Источник: tommcfarlin.com

I’m getting this nasty error Fatal error: Out of memory (allocated 18087936) (tried to allocate 77824 bytes). Weird thing is, it’s 17,25 mb (allocated) and it tried to allocate 76 kb. Memory limit is 128MB, and as you can see it’s not even close to that. VPS got ~400mb of free ram at that moment. It only happens when I’m posting something and not all the time.
I find it weird and don’t really know what can cause it.
Let me know if you need any additional info.

asked Apr 13, 2013 at 20:45

Igor Yavych's user avatar

9

The error says that the memory limit is 18M and not 128M. This means that somewhere the memory_limit is set to something different than 128M (local php.ini, or the application itself, since PHP can override this setting at run-time).

I would suggest that you first create a file called (say) phpinfo.php with the following contents:

<?php
phpinfo();
?>

and place it where your script runs. Then access the file with your browser and look for the actual memory_limit value. If it’s still showing 128M both for «global» and «local» value, then probably somewhere in your code, there’s a «ini_set(«memory_limit», $value);» call or something similar. Otherwise, if it says 18M, look for other places where this can be set:

  • Check your wp-config.php file
  • Check for any local php.ini file (look into the phpinfo.php page to see the location of the actual loaded php.ini file)
  • Check for any .htaccess files that contain such a directive

answered Apr 14, 2013 at 12:08

periklis's user avatar

periklisperiklis

10k6 gold badges61 silver badges66 bronze badges

7

Hope this helps, as I had the same issue:

You’re running into a limitation in WordPress’s own memory limit, not your PHP memory_limit. WordPress implemented this limit in order to prevent poorly written scripts from shutting down your whole PHP interpreter. Unfortunately, as you’ve noticed, it’s rather barebones.

The easiest way I’ve found to fix this is to install the Change Memory Limit plugin from WordPress plugin repository. It allows you to fix the issue without modifying any WP files manually.

The 64M default for the plugin will probably be fine for you.

Alternatively, if you don’t want to trust a third party plugin, add the following line to wp-config.php:

define('WP_MEMORY_LIMIT', '64M');

answered Apr 22, 2013 at 10:05

Glitch Desire's user avatar

Glitch DesireGlitch Desire

14.4k7 gold badges41 silver badges55 bronze badges

4

Got it from this http://wordpress.org/support/topic/fatal-error-out-of-memory-messages?replies=24#post-1929111, thought I’d share it with you guys :


THIS TO BE ENTERED IN THE WP-CONFIG FILE WHICH IS IN THE ROOT OF THE WORDPRESS SETUP:
ENTER AFTER : 
define('ABSPATH', dirname(__FILE__).'/');
THE FOLLOWING:

define('WP_MEMORY_LIMIT', '64M');

ALSO CREATE A PHP.INI WHICH SHOULD BE UPLOADED TO THE PLUGIN FOLDER IN WP-CONTENT:

 `memory_limit = 128M; //Maximum amount of memory a script may consume (64MB)
`

max_execution_time = 45;


upload_max_filesize = 15M;


post_max_size = 30M;

Hope this helps!

answered Apr 22, 2013 at 10:06

Hiren Pandya's user avatar

Hiren PandyaHiren Pandya

9791 gold badge7 silver badges20 bronze badges

Just an option that helped me debugging these errors.

If you have access to the .htaccess, you could try this:

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
php_value max_input_time 300

If that doesn’t help, you could try this to check the settings:

echo 'Max upload size: ' . ini_get('upload_max_filesize') . '<br />';
echo 'Max post size: ' . ini_get('post_max_size') . '<br />';
echo 'Memory limit: ' . ini_get('memory_limit');

I hope this works, for me it did.

answered Apr 16, 2013 at 14:49

Ron van der Heijden's user avatar

I am not sure this causes the error, but it is worth checking for.

Many of the most untraceable pathetic out of memory errors are caused by :

1) User defined exception handlers, causing exceptions therefore recursing.

2) The above + trying to fetch class information of object originating the exception, and the class information testing causes an autoload attempt, in which autoload throws another exception and therefore recursing.

Have you done something conflicting with WP error handling or autoload?

answered Apr 17, 2013 at 12:15

Volkan's user avatar

VolkanVolkan

2,2021 gold badge13 silver badges14 bronze badges

I install wp-memory-usage plugin by alexrabe on all my WordPress sites.

This plugin helps you to see what WordPress is seeing in terms of your PHP memory usage. Other approaches may show you the PHP settings at the server, however these settings are often overridden with various techniques the closer you get to a rendered page within the browser.

To set your max memory -> open your favorite text editor and create a file called php.ini; include in the file the following line:

memory_limit = 256M

Place a copy of the php.ini your WordPress root directory. I also place copies in: /wp-admin; /wp-content; and /wp-includes.

answered Apr 18, 2013 at 13:59

TECH N's user avatar

Add define('WP_MEMORY_LIMIT', '256M'); in your wp-config.php file. Its the easiest way.

answered Apr 20, 2013 at 13:26

aakash's user avatar

aakashaakash

3761 gold badge4 silver badges18 bronze badges

1

It looks as through somewhere in the site, the memory limit is being overwritten, do a site wide search in the code for ini_set('memory_limit' and see what is returned.

answered Apr 21, 2013 at 3:12

duellsy's user avatar

duellsyduellsy

8,3872 gold badges35 silver badges60 bronze badges

1

Given that your phpinfo() script returns the correct value for memory usage, this is obviously being set in WordPress somewhere, and is therefore overriding the Apache provided values, so using a .htaccess to apply this still won’t work.
This link (http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP) suggests that WordPress does its own memory management by default, so setting the (‘WP_MEMORY_LIMIT’, ‘256M’) in the wp-config.php is logical.

If you have shell access to the server hosting your site I would suggest going to the DocumentRoot of your wordpress install and running the following commands:

grep -R "18M" *
grep -R -e '(WP_MAX_MEMORY_LIMIT|WP_MEMORY_LIMIT)' *

This will search through your files for the string 18M (the value your memory limit seems to be set to in human readable terms) and the configuration options for the WordPress defined memory limit. I suspect that one of these commands will return positive output. You should then change the WP_MEMORY_LIMIT as suggested (although 256M may be a little high — try 64M initially, you don’t want to cause yourself potential problems).

answered Apr 22, 2013 at 9:59

Chris's user avatar

ChrisChris

465 bronze badges

4

Are you seeing an allowed memory size exhausted error in WordPress? This is one of the most common WordPress errors, and you can easily fix it by increasing the php memory limit in WordPress. In this article, we will show you how to fix WordPress memory exhausted error by increasing PHP memory.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

What is WordPress Memory Exhausted Error?

WordPress is written in PHP, which is a server-side programming language. Every website needs a WordPress hosting server for it to function properly.

Web servers are just like any other computer. They need memory to efficiently run multiple applications at the same time. Server administrators allocate specific memory size to different applications including PHP.

When your WordPress code requires more memory than the default allocated memory, you get to see this error.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx

Memory exhausted error displayed on a WordPress site

By default, WordPress automatically tries to increase PHP memory limit if it is less than 64MB. However, 64MB is often not high enough.

Having said that, let’s see how to easily increase PHP memory limit in WordPress to avoid memory exhausted error.

Increase PHP Memory Limit in WordPress

First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.

Next, you need to paste this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

define( 'WP_MEMORY_LIMIT', '256M' );

This code tells WordPress to increase the PHP memory limit to 256MB.

Once you are done, you need to save your changes and upload your wp-config.php file back to your server.

You can now visit your WordPress site and memory exhausted error should disappear now.

If you are new to WordPress, then take a look at our beginners guide on how to copy and paste code from the web.

We also have a step by step guide on how to find and edit wp-config.php file.

Note: If this solution does not work for you, then this means your web hosting service provider does not allow WordPress to increase PHP memory limit. You will need to ask your web hosting provider to increase your PHP memory limit manually.

That’s all we hope this article helped you solve WordPress memory exhausted error by increasing PHP memory limit. You may also want to see our step-by-step beginner’s guide to troubleshooting WordPress errors.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. We have been creating WordPress tutorials since 2009, and WPBeginner has become the largest free WordPress resource site in the industry.

Reader Interactions

Skip to content

Fatal error out of memory WordPress is caused by, as the message says, out of memory. WordPress itself is not memory hungry. According to WordPress memory requirements, 32MB is enough to run WordPress. In most cases with a decent amount of plugins, 128MB is more than enough. The default memory_limit in wp-setting.php is 128MB if you have a newer WordPress installation.

A WordPress out of memory is usually easy enough to fix. That is if you know your WordPress is out of memory. Fatal error out of memory WordPress is not given an error message every time. Sometimes you can experience whats called White screen of death. No error messages, no warning, no nothing. If you get a white screen of death it is often after trying to access the WordPress Admin page. Check out my WordPress admin blank page after login on how to solve that.

How to increase WordPress memory limit?

In the beginning of /wp-includes/default-constants.php 40MB is allocated to WordPress. Or 64MB if it is multisite. So if you need more than that, you should in the default-constants.php allocate more than the default value. If you feel like your site need 128MB, change the code to this: define( ‘WP_MEMORY_LIMIT’, ‘128M’ );

Please note that some WordPress hosts, or shared web hosting only allocate 8MB to php. If you are using an  unmanaged vps, dedicated server or a web host with access to the WordPress setting files, try the change above to increase php memory.

Check php memory usage

If you want to check php memory usage or how much memory your WordPress site is using, check out Server IP & Memory Usage Display. After installing the plugin, just go to your admin page and scroll down to the bottom. Really useful when debugging your memory needs for your site. You will see your php memory size and Php memory limit WordPress IP address and your php and OS version.

fatal error out of memory WordPress 2

If you liked this fatal error out of memory WordPress article, please check out my other WordPress articles.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.

i have a memory issue while NextgenGallery try to create the thumbnails.

Wp-Version is 3.4.1

Fatal error: Out of memory (allocated 29884416) (tried to allocate 2000 bytes) in
/xxx/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php
on line 179

But my memory is not exceeded:
PHP Version : 5.2.17 / 32Bit OS
Memory limit : 128 MByte
Memory usage : 27.75 MByte

I am getting desperate trying to solve this issue.

Many thanks in advance for any help,
Joe

asked Jul 16, 2012 at 13:22

JSS's user avatar

I’m not sure where you’re getting those stats, but I doubt that is showing you the amount of memory being used while processing the images. If you navigate to some memory use screen, you’re seeing the amount of memory currently allocated, which is now an entirely different process from when you were uploading images. The fact that Out of memory (allocated 29884416) is already larger than 27.75 MByte points to this.

answered Jul 16, 2012 at 14:02

Milo's user avatar

MiloMilo

77.1k3 gold badges116 silver badges159 bronze badges

1

this just means you need to make a small change in your .htaccess or create a php.ini to increase the allocated memory for WordPress.

You and your visitors will see this out of memory error when WordPress is trying to process something (in your case the thumbnails).

Try either of these to fix the problem
1. Create a file in your root /WordPress folder called php.ini , add this line in PHP.ini
memory_limit = 64M;
2. If you don’t have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 64M

You can also try increasing it to 128M or 256M

If that doesn’t work — contact your web host provider for their preferred method.

answered Aug 18, 2012 at 9:10

Damien's user avatar

DamienDamien

2,2112 gold badges13 silver badges25 bronze badges

2

Out-of-memory errors in WordPress are one of the most common errors that can occur with sites running on WordPress. WordPress themes and plugins are notorious for hogging up site resources and bogging down your site, especially if you have many of them. Un-optimized code can also be too demanding and easily start to eat up what memory you have available.

How Do I Fix Out of Memory Errors on WordPress?

You may be able to increase the memory available for your site by simply adding a single line of code to your wp-config.php file. To do this, follow these steps:

Step One: Go to the File Manager in your cPanel Interface.

Step Two: Find the wp-config.php file located with your WordPress installation and choose edit.

Step Three: Add the following line at the end just before the «Happy Blogging» line:

define('WP_MEMORY_LIMIT', '256M');

If this line already exists, increase the number to a higher value than what it was previously.

If on a Shared or Business hosting plan, this value will have a cap. The Shared hosting maximum PHP memory limit can be found here, and the Business hosting maximum PHP memory limit can be found here. If on a VPS, there would be no Hostwinds set limit.

This may or may not help, depending on what memory is available according to your php.ini file and the memory allowed per the hosting plan. It has the final say and can overwrite the above change. However, if your wp-config.php file didn’t have that line or had a lower amount than what the php.ini has, this will have a good probability of fixing it.

If it doesn’t fix it, then you can change the amount of memory allocated to the site in the php.ini file if you’re on a Cloud or dedicated server (below). If you’re on one of our shared hosting plans, you don’t have access to the php.ini file. Try the other fixes below, and if nothing works, it may be time to upgrade your hosting plan.

How Do I Increase Memory Using the php.ini File?

Cloud VPS and Dedicated hosting plan users can edit the php.ini file for the site. It’s typically found in the root of the directory if there is one. If not, you can create one.

Step One: Download or create the php.ini file in Notepad or your preferred text editor

Step Two: Add this line:

memory_limit=256M

Step Three: Upload it to the root directory of your site.

Step Four: Check to see if the problem is fixed

If this doesn’t correct the problem, you can increase the memory limit referenced above by replacing the memory limit in the above example with a value of your choosing.

Cleaning up your WordPress installation

This should be done now and then regardless of whether you’re getting errors or not. Doing these can improve the overall performance of your WordPress installation and reduce resource consumption.

  • Get rid of any plugins that you don’t need. Delete them – don’t just deactivate them and let them pile up in your plugin directory.
  • Empty the trash section and get rid of the revised versions of posts
  • Delete all those spam comments that have been piling up since you first started your site
  • A useful plugin that can be used to profile the Resource Consumption of other plugins is the P3 Prothe filer installed on your WordPress.

If you should have any questions or would like assistance, please contact us through Live Chat or by submitting a ticket with our Technical Support team.

Viewing 5 replies — 1 through 5 (of 5 total)

  • Moderator
    Yui

    (@fierevere)

    ゆい

    2Gb is enormous value. Even most heavy WordPress installations with many plugins are not supposed to eat more than 256-512 Mb, unless you are processing something really heavy (such as very high resolution images)

    You have to restart your webserver software (or PHP) after modifying php.ini
    You can check current limits under Dashboard: Tools>Health Check, Info tab

    I checked the info tab and both memory settings are 2048.

    Is there any way of checking what’s using so much memory?

    Moderator
    Yui

    (@fierevere)

    ゆい

    https://wordpress.org/plugins/query-monitor/
    You can try this for debugging (dont leave it active on production site, after you’ve finished to gather information)
    Its not much about memory, but still may provide some hints.

    Otherwise – keep checking PHP error logs.

    • This reply was modified 2 years, 8 months ago by Yui.

    Thanks for your help @fierevere.

    After troubleshooting with the plugin you recommended, the site was crashing without using up hardly any memory and it turned out to be a hosting issue.

    They recommended to add ‘RLimitMEM MAX’ to the .htaccess file, which seems to have done the trick.

    Moderator
    Yui

    (@fierevere)

    ゆい

    thanks for sharing problem root and solution.

  • Viewing 5 replies — 1 through 5 (of 5 total)

    As you may know, WordPress is built using PHP. This programming language is incredibly flexible, but it also has a few drawbacks. For example, if you don’t allocate enough memory for your WordPress installation, you might start running into the occasional “PHP Memory Exhausted” error.

    In a nutshell, this error means your server isn’t allocating enough resources for WordPress to execute the PHP scripts it needs to function properly. This issue can negatively affect your site’s functionality, but there are several ways you can fix and even prevent it.

    In this article, we’ll show you how to fix the memory exhausted problem by increasing your PHP memory limit. However, first, let’s talk about how to recognize this error and what it means!

    Why You’re Seeing a WordPress Memory Limit Error on Your Site

    As we mentioned earlier, the PHP memory limit error means you’re not allocating enough resources for your WordPress installation to function correctly. The problem usually presents itself with a message such as:

    The memory exhausted PHP fatal error.

    Don’t be scared by the word “fatal,” though. Your website isn’t broken, but you will need to make some changes to your WordPress installation if you want it to work properly. Specifically, you’ll want to increase your PHP memory limit.

    By “PHP memory limit,” we mean the amount of server memory that’s allocated to run PHP scripts. By default, that number should be around 64 MB or higher. In most cases, 64 MB is more than enough, however.

    Most hosting servers provide you with far more memory than that, so increasing the PHP allowed memory size shouldn’t negatively impact your website’s performance whatsoever. In fact, unless you’re using a cheap web host or you set up WordPress manually, your PHP memory limit shouldn’t be an issue at all.

    You can easily check to see what your PHP memory limit is by accessing your WordPress dashboard and navigating to Tools > Site Health > Info. Next, you can click on the Server tab and look for the PHP memory limit entry.

    A website with a high PHP memory size.

    Within the Server tab, you can also check other information such as your PHP version and the PHP time limit. The latter variable, which is in seconds, defines how long PHP scripts have to execute before they time out.

    For now, let’s focus on the PHP memory limit. As you can see, the above example has quite a high limit, which means that the website is unlikely to run into a WordPress Memory Exhausted error.

    If your site has a low memory limit (<64 MB), it’s in your best interests to increase it. There are a couple of ways you can do so.

    Get Content Delivered Straight to Your Inbox

    Subscribe to our blog and receive great content just like this delivered straight to your inbox.

    How to Resolve the WordPress Memory Limit Error (2 Methods)

    As far as WordPress errors go, this one has a clear-cut cause and solution. You’re not allocating enough memory for your PHP installation, so you need to increase that number. In this section, we’ll go over two methods you can use: one manual technique and one that requires your wallet.

    1. Increase the PHP Memory Allocated to Your Website Manually

    WordPress enables you to declare your allowed memory size manually by modifying one of two files: .htaccess and wp-config.php. However, changing your WordPress installation’s .htaccess file can lead to site-wide errors since that file governs how it interacts with your server.

    Increasing your PHP memory limit through wp-config.php is, in most cases, the safest option, and it’s remarkably easy to do. All you need is a Secure File Transfer Protocol (SFTP) client such as FileZilla that you can use to connect to your website.

    Once you access your website via SFTP, open the WordPress root folder and look for the wp-config.php file within it.

    A WordPress wp-config.php file.

    Open that file using a text editor, and you should see something like this:

    Editing a wp-config.php file.

    To increase your PHP memory limit, you can simply add a single line of code anywhere after the <?php tag and before the part of the file that reads “/* That’s all, stop editing! Happy blogging. */”.

    This is the line of code to add:

    define( 'WP_MEMORY_LIMIT', 'XXXM' );

    You’ll need to replace the “XXX” variable within that line with the amount of memory you want to allocate to PHP. As we mentioned before, the absolute minimum you should settle for is 64 MB.

    However, you can also double the number to play it safe or increase it even further. For example, if you set a PHP memory limit of 256 MB, it would look like this:

    define( 'WP_MEMORY_LIMIT', ‘256M’);

    Once you’re set on a number, save the changes to wp-config.php and close the editor. Now return to your WordPress dashboard and navigate to Tools > Site Health > Info > Server to see if the changes went through.

    In some cases, declaring your PHP memory limit manually won’t work because you don’t have the necessary permissions to change that value. If you can’t adjust your WordPress memory size manually, that leaves you with one other option.

    2. Upgrade Your Website’s Hosting Plan

    Typically, if you use a decent WordPress hosting provider, you won’t need to worry about increasing your PHP memory limit. One caveat is that if you’re using shared hosting, you’ll likely face limited resources. So if you’re encountering this error, it might be time to upgrade to a better hosting plan.

    Upgrading your hosting package will usually result in an increase in available PHP memory. That means you’re much less likely to run into a WordPress memory limit error. The only limiting factor is your budget.

    If you can’t upgrade hosting plans right now, it might be worth contacting your provider’s support team and seeing if they can increase your PHP memory limit on their end. If they can’t, it might be time to switch to a better WordPress host that offers high PHP memory limits on affordable plans.

    Skip the Stress

    Avoid troubleshooting when you sign up for DreamPress. Our friendly WordPress experts are available 24/7 to help solve website problems — big or small.

    Want More WordPress Error Tips?

    Once you increase PHP memory on your WordPress website, we can help tackle other issues. We’ve put together several tutorials to help you troubleshoot every error message:

    • How to Fix Common WordPress Errors
    • How to Troubleshoot the WordPress White Screen of Death (WSoD)
    • How to Fix the 500 Internal Server Error in WordPress
    • How to Fix Syntax Errors in WordPress
    • How to Fix the WordPress Not Sending Email Issue
    • How to Fix the Error Establishing Database Connection in WordPress
    • How to Fix WordPress Error 404 Not Found
    • How to Fix White Text and Missing Buttons in WordPress Visual Editor
    • How to Fix the Sidebar Below Content Error in WordPress (In 3 Steps)
    • What to Do When You’re Locked Out of the WordPress Admin Area
    • How to Fix the WordPress Login Page Refreshing and Redirecting Issue

    Want more information on WordPress site management? Check out our WordPress Tutorials, a collection of guides designed to help you navigate the WordPress dashboard like an expert.

    Increasing PHP Memory Limit

    Running into a PHP fatal error can be worrying, but it’s not necessarily a cause for concern. Learning how to increase your PHP memory limit is relatively simple if you don’t mind using an SFTP client and adding a single line of code to one of WordPress’ core files.

    The alternative is to upgrade your hosting plan or opt for a better provider. Most WordPress-friendly hosting options offer high limits by default, so you’ll never run into a PHP memory exhausted error ever again.

    If you’re ready to use a web host optimized for WordPress websites, check out our DreamPress hosting packages! We offer optimized WordPress setups, so you spend less time troubleshooting errors and more time working on your website.

    Have you ever gotten this Linux “out of memory” error when working with your WordPress site?

    Fatal error: Out of memory (allocated 63963136) (tried to allocate 7864320 bytes) in [path]/wp-content/plugins/wordfence/lib/wfBrowscapCache.php.php on line 16388

    If you Google around to solve this problem, almost all of the advice you’ll get is to increase your PHP and WordPress memory limits, or add memory to your server, or to remove plugins.

    I didn’t want to just increase memory. I wanted to solve the root cause of the problem. The site was running on an Amazon EC2 small instance with Amazon AMI. It should not be running out of memory!

    If you want to go directly to my results, jump ahead to my recommendations. Otherwise, here’s my story:

    How I Investigated This Problem

    When I first got this error, I installed the TPC! Memory Usage Plugin on my live site. [Note: I no longer recommend that plugin since it’s not maintained. Use Server IP & Memory Usage Display instead.]

    I installed this plugin on my local development site as well and was totally blown away when I compared the memory usage on my local site vs. live site:  the same site with the same plugins was using 34.13MB on my local server and 60.0MB on the live site. WOW!!!

    How could this be? There must have been something in the server setup that caused the discrepancy. Googling some more, I read that PHP5.4 uses significantly less memory than PHP5.3, by a huge amount, on the order of cutting it in half. Sure enough, I checked and found out that my local server was running PHP5.4 while my live server was running PHP5.3. It seemed like a smoking gun, but I needed to do one more experiment to be sure.

    I had another WordPress site running on Amazon EC2 with Amazon AMI, running PHP5.3. Memory usage for that was 47.8MB. After I upgraded that server to PHP5.4, it used 30.0MB. It was clear, switching from PHP5.3 to PHP5.4 saved almost 18MB of memory! That is huge!!!

    TPC Memory Report
    This report shows my memory usage before and after upgrading to PHP5.4. The difference is huge.

    My Number One Recommendation – Upgrade PHP

    Based on these findings, my number one suggestion to reduce WordPress memory usage is to upgrade from PHP 5.x on your server to PHP 7.x, which is even faster and more memory-efficient. I’m now using PHP 7.3 on all of my personal and client sites.

    If you are on shared hosting like GoDaddy, 1&1, Dreamhost, etc., there is often a button in the control panel to upgrade. Simple as that.

    If you are running your own Linux server, it’s more complicated. Here is an article describing what I did to upgrade from PHP5.3 to PHP5.4 on Amazon AMI. (This procedure also works for upgrading to PHP5.5 and beyond).  Note that there are other solutions to reducing PHP memory usage like Xcache. I’m considering that to be an advanced solution beyond the scope of this article.  If you want to try that, go for it and let me know how it goes in the comments!

    Be sure to re-test your site and plugins after you upgrade, as there might be some old code not compatible with PHP 7.x.  I have not encountered problems with PHP 7.3 on my WordPress sites.

    This Can Also Fix HTTP ERROR 500

    On a different site, I was getting HTTP ERROR 500 when I tried to edit a page. Viewing pages on the front end was fine. I suspected some sort of memory issue.  After trying a bunch of other stuff, I simply upgraded PHP from 7.0 to 7.1 and it solved the problem!

    And Don’t Forget..

    Of course, it also helps to delete unused plugins. If you want, you can install the Server IP & Memory Usage Display plugin and deactivate plugins on at a time to see their contribution to your memory usage. (Just remember to deactivate it when you’re done, because it contributes to memory usage as well). I can almost guarantee you that none will save you 18MB like switching to PHP5.5 or greater might do! But, eliminating plugins might be just enough to stop your memory errors from happening.

    If you are not able to upgrade to PHP7+, and you can’t delete any more plugins, then you can always increase your allowable memory usage and/or get more memory for your server like the vast majority of articles recommend. The Server IP & Memory Usage Display plugin will tell you how much memory is allocated to WordPress (usually 40MB) and to PHP (usually 64MB or 128MB). You can Google around to see how to increase these limits.

    But, I prefer to solve the root cause of the problem rather than treat the symptoms!

    I hope my experience was helpful to you. Please comment on your findings and experiences about WordPress memory usage! – Brian

    Brian Shim

    I am a freelance web developer and consultant based in Santa Monica, CA who uses WordPress, PHP, and JavaScript to create websites and web applications for businesses, nonprofits, and organizations.

    facing a PHP Fatal Error: Out of memory error in your WordPress website ? This is one of the most common errors in WordPress, which you can easily fix it by increasing the Php memory limit in WordPress setup website. In today article, we will show you how to fix Fatal error: Out of memory error in worpdress.

    Increase PHP Memory Limit in WordPress to Fix Fatal error: Out of memory worpdress

    To increase memory limit in WordPress site need to edit the wp-config.php file which is located in WordPress site’s root folder, with use of FTP access or CPanel > File Manager you able to easily reach at WordPress setup root directory and find wp-config.php file which you need to edit for Fix Fatal Error: WordPress Memory Exhausted Error by Increase PHP Memory.

    Next, Add following WP_MEMORY_LIMIT line in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

    // increase memory limit in WordPress
    define( 'WP_MEMORY_LIMIT', '512M' );  // change 512M according need
    
    

    Above code tells WordPress to use memory limit ‘512M’ instead of default memory limit avail in WordPress setup server and this way we able to increased the PHP memory limit and fix Fatal error: Out of memory worpdress / WordPress Memory Exhausted Error

    If you getting errors while working in the wp-admin area of WordPress, try adding the WP_MAX_MEMORY_LIMIT code beneath the memory limit code,
    like so:

    // increase memory limit in WordPress
    define('WP_MEMORY_LIMIT', '512M' );  // change 512M according need
    define('WP_MAX_MEMORY_LIMIT', '128M');
    

    Basically:
    WP_MEMORY_LIMIT = WordPress front end
    WP_MAX_MEMORY_LIMIT = WordPress back end

    Make sure, for safety you taken original file backup before edit wp-config.php and uploaded / Save edited wp-config.php in WordPress setup Root directory. in case it anything wrong happen than upload back your backup file and contact our Experience WordPress Developer who ready to help in solve Fatal Error: WordPress Memory Exhausted Error in free of cost 🙂

    After increased Memory limit with edit wp-config.php now visit your WordPress site and memory exhausted error should disappear now.

    Important Note: If given above solution not work for you, then it means your hosting service provider not allow to increase PHP memory limit by editing wp-config.php file. and you need to contact your web hosting support team and request them to increase PHP memory limit manually for your WordPress hosting account.

    If you Fixed WordPress Memory Exhausted Error by Increase PHP Memory in any other way please share in comment.

    Enjoy Life 🙂

    i have a memory issue while NextgenGallery try to create the thumbnails.

    Wp-Version is 3.4.1

    Fatal error: Out of memory (allocated 29884416) (tried to allocate 2000 bytes) in
    /xxx/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php
    on line 179

    But my memory is not exceeded:
    PHP Version : 5.2.17 / 32Bit OS
    Memory limit : 128 MByte
    Memory usage : 27.75 MByte

    I am getting desperate trying to solve this issue.

    Many thanks in advance for any help,
    Joe

    asked Jul 16, 2012 at 13:22

    JSS's user avatar

    I’m not sure where you’re getting those stats, but I doubt that is showing you the amount of memory being used while processing the images. If you navigate to some memory use screen, you’re seeing the amount of memory currently allocated, which is now an entirely different process from when you were uploading images. The fact that Out of memory (allocated 29884416) is already larger than 27.75 MByte points to this.

    answered Jul 16, 2012 at 14:02

    Milo's user avatar

    MiloMilo

    77.5k3 gold badges118 silver badges161 bronze badges

    1

    this just means you need to make a small change in your .htaccess or create a php.ini to increase the allocated memory for WordPress.

    You and your visitors will see this out of memory error when WordPress is trying to process something (in your case the thumbnails).

    Try either of these to fix the problem
    1. Create a file in your root /WordPress folder called php.ini , add this line in PHP.ini
    memory_limit = 64M;
    2. If you don’t have access to PHP.ini try adding this to an .htaccess file:
    php_value memory_limit 64M

    You can also try increasing it to 128M or 256M

    If that doesn’t work — contact your web host provider for their preferred method.

    answered Aug 18, 2012 at 9:10

    Damien's user avatar

    DamienDamien

    2,2112 gold badges13 silver badges25 bronze badges

    2

    Понравилась статья? Поделить с друзьями:
  • Wordpress ошибка 500 после переноса
  • Wordpress ошибка 500 после обновления
  • Wordpress ошибка 404 nginx
  • Wordpress ошибка 403 доступ запрещен как исправить
  • Wordpress ошибка 401