Ваш сайт WordPress нуждается в компьютерной памяти для работы. Иногда выделенной памяти может быть недостаточно для запуска вашего сайта, и вы увидите такую ошибку ограничения памяти WordPress:
fatal error: allowed memory size of 67108864 bytes exhausted
Вторая ошибка, указывающая на нехватку памяти в WordPress, — это белый «экран смерти». Если ваш сайт не работает, и все, что вы видите, это белый экран, у WordPress заканчивается память.
Веб-серверы устанавливают ограничение на объем памяти. Ограничение памяти является необходимой функцией для защиты серверов. Веб-серверам требуется достаточно памяти для одновременного запуска многих приложений.
Если память, используемая PHP-скриптами, не ограничена, плохо написанный скрипт может использовать всю память. Это приведет к сбою сервера и сделает ваш сайт и все другие сайты на этом сервере недоступными.
Поскольку WordPress состоит из скриптов, написанных на PHP, он связан ограничениями памяти, установленными для PHP-скриптов.
Таким образом, если одному из ваших скриптов требуется больше памяти, чем может быть выделено, у него заканчивается память, и вы видите ошибку WordPress allowed memory size exhausted.
Когда это происходит, вы почти всегда можете проследить проблему до плагина или в некоторых случаях до темы. Маловероятно, что ваши основные скрипты WordPress потребуют больше, чем выделенная память для запуска.
Как исправить эту ошибку ограничения памяти WordPress
Существует два основных способа исправить фатальную ошибку. Вы можете либо увеличить лимит памяти WordPress, либо избавиться от скрипта, который требует больше памяти.
Увеличение лимита памяти PHP в WordPress — простое решение
Эта ошибка указывает на то, что на вашем сайте закончилась память. Очевидный способ исправить это-увеличить объем памяти, который может быть выделен сценарию.
По дизайну WordPress сначала пытается увеличить ваш лимит памяти до 64 Мб. Появление этой ошибки указывает на то, что этого размера все еще недостаточно, или в некоторых случаях ваш сервер предотвращает выделение большего объема памяти.
Вы можете вручную увеличить лимит памяти в WordPress, отредактировав файл wp-config.
Для этого подключитесь к своему сайту с помощью FTP-клиента FileZilla.
При подключении папки и файлы вашего сайта будут отображаться в правом нижнем углу экрана. Найдите папку, содержащую все ваши файлы WordPress, и дважды щелкните ее, чтобы открыть.
В этой папке найдите файл wp-config, щелкните его правой кнопкой мыши и выберите команду просмотр/редактирование.
Когда файл откроется в текстовом редакторе, прокрутите его вниз, чтобы найти строку “That’s all, stop editing! Happy blogging.” Вставьте следующий код над этой строкой.
define( 'WP_MEMORY_LIMIT', '128M' )
Сохраните этот файл и закройте редактор. FileZilla предложит вам загрузить отредактированный файл.
Теперь перезагрузите свой сайт. Проблема должна быть исправлена и ваш сайт должен отображаться правильно.
Примечание: строка, которую мы добавили выше, увеличила память до 128 мегабайт. Если вы все еще получаете ошибку, то этот размер памяти все еще может быть недостаточным. Вы можете исправить это, изменив ограничение памяти PHP на 128M, 256M или даже 512M.
Альтернативное решение-найти скрипт, вызывающий ошибку
Исправление выше может помочь вам быстро избавиться от проблемы. Но бывают ситуации, когда лучше найти скрипт, требующий больше памяти, и удалить его.
Если, например, вам нужно увеличить выделенную память выше 256M, то этот скрипт уже занимает слишком много памяти. Это может испортить производительность вашего сайта.
В некоторых случаях ваш хост может вообще не разрешить вам увеличить объем памяти. В этом случае вы можете связаться с вашим хостом и попросить его увеличить объем памяти. Или еще лучше, вы можете отследить причину проблемы и избавиться от нее.
В первую очередь нужно проверить ваши плагины. Если вы установили плагин WordPress незадолго до возникновения этой ошибки, то в нем, скорее всего, причина.
Если отключение плагина не решает проблему, то возможно виновата ваша текущая активная тема.
Как удалить плагин и тему без доступа к админ панели узнайте в следующих статьях.
Among much known WordPress errors which users face, WordPress Memory Exhausted Error is one of the most common errors. If you are seeing this error on your WordPress website, then this is because the PHP memory limit set in your WordPress is not enough for your website to perform the tasks which you are performing. This “WordPress fatal error: allowed memory size of 67108864 bytes exhausted” can be solved easily by increasing PHP memory limit.
What does WordPress Allowed Memory Exhausted Error Means?
This error means that your WordPress do not have enough memory to perform the tasks which you are trying to execute. When your WordPress needs more memory as compared to its allocated memory, it will display this error.
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx
This WordPress php memory limit error can be easily resolved by increasing the PHP memory limit in wp-config.php file of your WordPress installation.
Increase WordPress PHP Memory Limit
In order to increase WP memory limit, you need to edit wp-config.php file which is located in the root directory of your WordPress installation. If WordPress is installed on your main domain (like www.example.com) then wp-config.php file will be located in the public_html folder of File Manager in your hosting control panel (cPanel). You can access and edit this file through cPanel or using an FTP Client (like FileZilla).
Now search for the below line in your wp-config.php file:
/* That’s all, stop editing! Happy blogging. */
Now, copy and paste the below line of code just after that line, as shown in the screenshot.
define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
This code will now increase your WordPress PHP memory limit to 256MB. After saving the wp-config.php file you can now visit your website to see if the error has been resolved or not. In most cases this simple method should resolve the issue.
But in case that you are still seeing this WordPress fatal error: allowed memory size of 67108864 bytes exhausted, then it is because that your web hosting provider is not allowing to increase the WP memory limit by WordPress. In this case, you need to ask your web hosting provider to increase the PHP memory limit for your account.
Categories / WordPress FAQ
PHP memory limits prevent poorly written scripts from using all of the memory resources on the server. To avoid PHP memory limit errors all WordPress sites should set memory limit values to 256MB via the wp-config.php, .htaccess or php.ini files.
Adjusting this value will satisfy the memory requirements of popular plugins like WooCommerce, WPML, Multisite and site builders. This prevents your site or admin dashboard from displaying the Fatal error: Allowed memory size of XXXXXXXX bytes exhausted (tried to allocate XXXX bytes) error message.
The default 40MB from WordPress is simply not enough memory to meet the demands of complex plugins and administrative actions in your WordPress dashboard. Thankfully there are 4 ways you can adjust these limits in WordPress.
Fixing PHP Memory Errors
1. PHP Memory Limit Error Causes
In order to prevent poorly written scripts from using up all the memory resources on your server a maximum memory limit (per script) is enabled by default. Out of memory errors are caused when scripts try to utilize more memory than wordpress has allocated.
By default wordpress sets PHP memory limits to 40MB for a single site and 64MB for multisites. Scripts that violate those thresholds cause error messages to show up like this one.
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6969 bytes)
2. Recommended Memory Limit Settings
Changing your memory limit setting increases PHP Memory only for WordPress, not other applications. Furthermore, you will need to change the memory values for both your public pages and admin dashboard.. When executing administrative tasks (admin dashboard) more memory is often necessary.
A 256MB Limit and 512MB MAX Limit (wp-config.php) would be appropriate on shared hosting. Popular plugins like WooCommerce, WPML, multisite and most site builders require 256M to run properly.
If you are on a Cloud, VPS or Dedicated server you might wish to increase memory limits for public and admin even further. Limits could be increased to 512M for public pages and 1024M for the admin dashboard.
-
- define( ‘WP_MEMORY_LIMIT’, ‘256M’ );
- define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ );
By default, WordPress will attempt to increase memory allocated to PHP to 40MB (located in /wp-includes/default-constants.php) for single site and 64MB for multisite, so the when editing your (located in root directory) wp-config.php you should enter an input higher than 40MB / 64MB respectively.
3. Public vs Admin Memory Limits
WordPress distinguishes between public facing page memory and admin memory by adding “MAX” to the code. It’s a terrible naming scheme dating back to WordPress 2.5, but nobody dares change it now.
- define(‘WP_MEMORY_LIMIT’, ‘256M’); Public Page Memory
- define( ‘WP_MAX_MEMORY_LIMIT’, ‘512M’ ); Admin Dashboard Memory
4. Bytes to MegaBytes Conversion Chart
If your website sends out an error message with specific byte sizes you can use this handy Bytes To Megabytes Conversion Calculator tool to estimate what memory limit has been exceeded.
1 byte is also equal to 0.00000095367432 megabytes = 2-20 megabytes in base 2 (binary) system.
| Memory Limit Bytes | Megabytes |
|---|---|
| PHP: Fatal Error: Allowed Memory Size of 4194304 Bytes Exhausted | 4 MB |
| PHP: Fatal Error: Allowed Memory Size of 8388608 Bytes Exhausted | 8 MB |
| PHP: Fatal Error: Allowed Memory Size of 16777216 Bytes Exhausted | 16 MB |
| PHP: Fatal Error: Allowed Memory Size of 33554432 Bytes Exhausted | 32 MB |
| PHP: Fatal Error: Allowed Memory Size of 67108864 Bytes Exhausted | 64 MB |
| PHP: Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted | 128 MB |
| PHP: Fatal Error: Allowed Memory Size of 268435456 Bytes Exhausted | 256 MB |
| PHP: Fatal Error: Allowed Memory Size of 536870912 Bytes Exhausted | 512 MB |
| PHP: Fatal Error: Allowed Memory Size of 1073741824 Bytes Exhausted | 1024 MB (1GB) |
5. Accessing wp-config.php / php.ini / .htaccess
There are three ways you can easily access the needed wordpress files to adjust memory limits. You can access files using your control panel (Cpanel) after logging into your host, use an FTP program like Filezilla or install a wordpress plugin.
Navigate to the root directory of your wordpress installation. If you are in the control panel you might to click on the “View” link in the upper right corner and make sure the checkmark for “show hidden files” is selected.
- Cpanel – Control panel in your hosting admin dashboard
- Filezilla – Free FTP software to transport files
- WPCF – Free plugin that allows you to edit wp-config
6. Edit Your wp-config.php File
Accessing wp-config through Cpanel is the easiest method of changing your memory limit values in wordpress. It is located in the root directory of your wordpress installation after scrolling down to the bottom. Right click on the wp-config.php file, paste the memory limit values we provided and click save.
Alternatively you can use the search option (upper right corner) by typing in “wp-config” exactly as show and clicking “Go”. You also have the option to search through “All Your Files” or in a specific directory by clicking the drop down arrow.
Add this right above the line that says /* That’s all, stop editing! Happy publishing. */
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
Your server PHP memory limit will be different than your wordpress memory limit. Your host will set the server memory limit for all applications. Editing the wordpress memory limit settings only applies to wordpress.
7. Edit Your php.ini File
If you have access to your php.ini file, change the memory limit value. If you don’t have a php.ini file you can create one. If your line shows 40MB or 64MB try changing the value to “256M”
memory_limit = 256M ; Maximum amount of memory a script may consume (64MB)
Creating a php.ini file can be done by navigating to your yourdomain/wp-admin and clicking +FILE (top left corner) in cpanel. Name the newly created file “php.ini” and click “create new file”.
8. Edit your .htaccess File
If you don’t have access to PHP.ini or prefer not to edit wp-config.php try adding this to an .htaccess file:
php_value memory_limit 256M
The .htaccess file is located in your root directory. You can add your code right above “# END WordPress” at the bottom of the file.
9. Edit Using WPCF Plugin
Its generally bad to use plugins for tasks that you can easily do manually. If you just can’t seem to figure out how to change the wp-config using cpanel or FTP you can use a handy plugin called WordPress Config File Editor (WPCF).
After downloading and activating the plugin you can edit the wp-config by editing the memory limit (public pages) and max memory limit (admin dashboard) in the field boxes provided. Recommended values are 256M and 512M respectively.
Should you not feel comfortable in trying the above methods, or the above did not work for you, you need to talk to your hosting about having them increase your memory limit.
Some hosts do not allow changing your PHP memory limit, in which case you would have to contact your hosting support by emailing or opening a support ticket. Other (shared) hosts put a cap of 756M on the allowed memory limit. If you have Cloud, VPS or a Dedicated server these limits can be increased even further.
11. Troubleshooting Memory Limit Errors
If you have recently added a plugin to wordpress and encountered the fatal error memory limit message there is a high probability the culprit is the plugin you just installed. If you have increased your memory limits to 1024M and are still getting fatal error messages, its time to get serious about troubleshooting.
What about memory error messages that seemingly come out of nowhere?
Without getting too technical two options exist for detecting plugins that eat up server resources. One well known scan is P3 Profiler which scans the load time and query count of all the plugins used during your site load. The only trouble is its outdated, with 3 major WordPress releases since its last update.
A second option Query Monitor requires a bit more technical knowledge. It provides a wealth of information about your server and database configuration, peak memory usage and query count. This information combined with a basic waterfall chart from GT Metrix or Pingdom can help out big time.
In case you didn’t already know certain plugins are well known resource hogs. Here are some that make the list.
- Wordfence (Security/Firewall)
- BackupBuddy (Backup Programs)
- Site Builders (Divi, Elementor, Flatsome, Beaver)
- WooCommerce (Ecommerce store)
- BuddyPress (Forums & Message Boards)
- Disqus (Commenting)
- Add This (Social Media)
- Revolution Slider (Slider Plugins)
12. Memory Limit Key Points
- Wordpress separates memory limits by public pages (WP_MEMORY_LIMIT) and admin pages (WP_MAX_MEMORY_LIMIT)
- Admin pages (dashboard) require more memory than public pages (your website).
- By default WordPress allocates 40MB of memory. Change this to 256M (public pages) and 512M (admin pages) in wp-config.php
- Several plugins are known resource hogs and should be avoided or substituted for light weight options.
- WooCommerce, WPML, Multisite, Forums and Site Builders require a minimum of 256MB.
- Most hosting companies allow you to increase memory limits (some don’t) so contact your host as needed.
- WordPress memory limits are set on a per script basis, not the combined total. Limits are ultimately capped by your server resources.
- The easiest way to change memory limits is through cpanel and editing wp-config.php file in your root directory.









