Viene visualizzato un messaggio di errore di esaurimento della memoria consentita in WordPress?
Questo è uno degli errori più comuni di WordPress e si può correggere facilmente aumentando il limite di memoria PHP in WordPress.
In questo articolo vi mostreremo come correggere l’errore di esaurimento della memoria di WordPress aumentando il limite di memoria di PHP.
Che cos’è l’errore di WordPress Memory Exhausted?
L’errore “WordPress memory exhausted” (memoria esaurita) è un messaggio che potreste vedere se il vostro sito web fatica ad eseguire le attività.
WordPress è costruito utilizzando PHP, un linguaggio di programmazione lato server che ha bisogno di memoria per funzionare.
Proprio come qualsiasi altro computer, i server web hanno una quantità limitata di memoria per eseguire più applicazioni contemporaneamente. I fornitori di hosting WordPress assegnano dimensioni di memoria specifiche a diverse applicazioni, tra cui PHP.
Quando il codice di WordPress necessita di più memoria di quella allocata in modo predefinito, viene visualizzato questo messaggio di errore:
Errore irreversibile: Memoria consentita di 33554432 byte esaurita (ha tentato di allocare 2348617 byte) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx
È possibile che il sito WordPress stia esaurendo la memoria del server:
- Un gran numero di immagini, video e altri tipi di media
- Un sacco di plugin WordPress inutilizzati
- Ha superato le risorse del suo piano di hosting
Di default, WordPress cerca di aumentare automaticamente il limite di memoria di PHP se è inferiore a 64 MB. Tuttavia, spesso 64 MB non sono sufficienti.
Detto questo, vediamo come aumentare facilmente il limite di memoria di PHP in WordPress per evitare l’errore di memoria esaurita.
È possibile utilizzare i collegamenti rapidi riportati di seguito per navigare nell’esercitazione:
Nota: alcuni di questi metodi richiedono la modifica diretta dei file di WordPress. Suggeriamo di eseguire prima un backup del sito web per evitare che appaiano ulteriori errori sul sito.
Opzione 1: Modifica del file wp-config.php
Per prima cosa, è necessario modificare il file wp-config.php sul sito WordPress. Si tratta di uno dei file principali di WordPress, situato nella directory principale, solitamente denominata public_html.
È necessario utilizzare un client FTP come FileZilla o il file manager del pannello di controllo del web hosting.
Quindi, è necessario incollare la seguente riga nel file wp-config.php, subito prima di quella che dice: Questo è tutto, smettete di modificare! Buon blog.
define( 'WP_MEMORY_LIMIT', '256M' );
Questo codice indica a WordPress di aumentare il limite di memoria di PHP a 256 MB.
Per maggiori dettagli, consultate la nostra guida passo-passo su come trovare e modificare il file wp-config.php.
Una volta terminato, è necessario salvare le modifiche e caricare il file wp-config.php sul server.
Ora potete visitare il vostro sito WordPress e l’errore di memoria esaurita dovrebbe essere scomparso.
Opzione 2: modifica del file .htaccess
Il metodo successivo consiste nel modificare il file .htaccess. Anche questo file si trova nella cartella principale del sito web di WordPress.
È necessario incollare il seguente codice prima della riga che dice #END WORDPRESS
.
php_value memory_limit 256M
Simile al codice precedente, indicherà a WordPress di aumentare il limite di memoria di PHP a 256MB.p
Dopodiché, è sufficiente salvare le modifiche e caricare nuovamente il file sul server web. Ora è possibile riaprire il sito web di WordPress per vedere se l’errore relativo al limite di memoria è stato eliminato.
Se non riuscite a trovare il file .htaccess, selezionate la nostra guida sui motivi per cui il file .htaccess potrebbe mancare e su come trovarlo.
Opzione 3: selezionare il file php.ini
Se i metodi sopra descritti non funzionano, si può controllare il file php.ini.
php.ini è un file che controlla le impostazioni di PHP, tra cui la versione di PHP e gli script PHP. Non è un file del nucleo di WordPress, perché di solito è gestito dal fornitore di hosting.
È possibile selezionare il codice per vedere il limite di utilizzo della memoria PHP. Per maggiori dettagli, si può consultare la nostra guida su come trovare e modificare il file php.ini.
Tuttavia, poiché si tratta di un metodo avanzato, vi consigliamo di contattare il team di assistenza del vostro fornitore di hosting per verificare se è possibile aumentare manualmente il limite di memoria di WordPress. In caso contrario, si potrebbero verificare ulteriori errori.
Per maggiori informazioni, potete leggere la nostra guida su come richiedere correttamente il supporto di WordPress.
Opzione 4: Aggiornamento dell’hosting WordPress
Se si verifica costantemente l’errore di memoria esaurita, potrebbe essere un segno che il sito web ha superato l’attuale piano di hosting.
Man mano che il sito web attira più visitatori e aggiunge più contenuti, sono necessarie più risorse per funzionare senza problemi. L’aggiornamento a un piano con una maggiore allocazione di memoria può essere una soluzione permanente.
Considerate di aggiornare il vostro hosting WordPress se:
- Avete provato le soluzioni precedenti ma l’errore persiste.
- Il vostro sito web è cresciuto significativamente in termini di traffico o di contenuti.
- Si prevede di aggiungere caratteristiche o funzionalità che richiedono maggiori risorse.
Bluehost ospita piani di hosting WordPress affidabili e convenienti, in grado di adattarsi alle esigenze del vostro sito web. Fornisce una piattaforma di facile utilizzo, ottimizzata specificamente per WordPress, che rende facile la gestione del sito web.
Se si utilizza il nostro codice coupon Bluehost, è possibile ottenere fino al 61% di sconto sul primo acquisto. Fai clic sul pulsante qui sotto per ottenerlo:
Come evitare di esaurire la memoria di WordPress
Ora che avete corretto l’errore di esaurimento della memoria di WordPress, ecco alcuni passaggi proattivi per evitare che si ripeta:
- Disattivare i plugin inutilizzati. Molti plugin contribuiscono all’utilizzo della memoria. Esaminate regolarmente i plugin attivati e disattivate quelli che non utilizzate attivamente per liberare memoria per le attività essenziali.
- Ottimizzare le immagini. Le immagini di grandi dimensioni possono essere un problema di memoria. Considerate l’utilizzo di un plugin come EWWW Image Optimizer per comprimere automaticamente le immagini prima di caricarle sul sito.
- Utilizzate un plugin di caching. I plugin di caching memorizzano i dati del sito web, riducendo la necessità di WordPress di rigenerarli a ogni visita. Ciò può migliorare significativamente le prestazioni del sito web e ridurre l’utilizzo della memoria.
Speriamo che questo articolo vi abbia aiutato a risolvere l’errore di esaurimento della memoria di WordPress aumentando il limite di memoria di PHP. Potreste anche voler consultare la nostra guida passo-passo per principianti alla risoluzione degli errori di WordPress e le nostre scelte di esperti sui migliori plugin di WordPress per far crescere il vostro sito.
Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.
Syed Balkhi
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
mohadese esmaeeli
With your permission, I’d like to add a note for users to the article:
Please note that htaccess is a hidden file. First, check if it exists. In case you couldn’t find the .htaccess file in your hosting, you can create one using text editor programs like Notepad. Simply create a file named htaccess. Alternatively, in the public_html directory, click on “New File” and create a file with the same name.
mohadese esmaeeli
I have encountered this issue multiple times, and it seems to be one of the most common problems in the WordPress domain. Each time, I either contacted the hosting support or edited the htaccess file to resolve the issue. The htaccess file appears to be like a magic solution, and whenever an issue arises, it can be quickly reviewed and fixed.
Mrteesurez
I used to encounter some errors like this on my websites but I didn’t know what to do. Something when I tried to solve it, I just uninstall the step and re-install it back and upload the backup.
I noticed the problems still persist, when I enable wp debug mode, t then see the exact errors and the it’s source.
I later find this guide and implented it and it works.
Thanks.
WPBeginner Support
Glad to hear our guide was helpful!
Admin
karma tsheten
AFter updating my .htaccess it gives me this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
WPBeginner Support
To be safe, for the internal server error we would recommend going through the steps in our article below:
https://www.wpbeginner.com/wp-tutorials/how-to-fix-the-internal-server-error-in-wordpress/
If removing the code from the htaccess solves the issue, we would recommend reaching out to your host to see if they have a setting that could be the source of the conflict.
Admin
Jiří Vaněk
Regarding the .htaccess file, be cautious. Many shared web hosting providers may have directives for increasing the memory limit disabled. Such a directive in the .htaccess file can cause a 500 error on the website, requiring its removal or commenting out. Be careful with this. Sometimes, simply increasing the memory limit may not solve the problem but rather delay it, like a painkiller. The pain might subside, but it doesn’t mean the cause has been resolved. Therefore, while increasing the memory limit might seem like a solution, it’s also important to check what is consuming the memory. Sometimes, people increase the memory limit from 512 MB to 1024 MB without considering whether it’s necessary, and whether the memory limit isn’t masking an underlying issue on the website.
WPBeginner Support
Thank you for sharing your feedback on the htaccess change. Unless the host has very strict rules in place adding to the htaccess shouldn’t cause an error it is more likely to not work and would require you reach out to the host to request an override.
Admin
ROOK
SAVED THE DAY!! TY
WPBeginner Support
Glad our guide could help!
Admin
Qamar Shafique
Thanks for this help.
WPBeginner Support
You’re welcome!
Admin
Aisha
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” and I also change the size of Memory_limit of Php.ini file
WPBeginner Support
As we state in the article, if our code does not work, there is a good chance your hosting provider is overriding the memory limit and you would need to reach out to your host to fix the error.
Admin
Sohaib Siddiq
It doesn’t solve my problem still shows an error after placing the code “define( ‘WP_MEMORY_LIMIT’, ‘256M’ );” & this is my front-end page showing
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 8192 bytes) in /home/X/wp-includes/class-wp-dependencies.php on line 260
WPBeginner Support
If the code does not work for you, we recommend reaching out to your hosting provider as they may have a limit set on their end that could be the root of the issue.
Admin
Zachary Murri
Thank you so much <3
WPBeginner Support
You’re welcome
Admin
Bogosi
Thank you for this!
WPBeginner Support
You’re welcome!
Admin
Devox
Super! it solved the problem quickly ,thank you very much
WPBeginner Support
Glad our guide was helpful!
Admin
Ifedayo
Thank you, this was helpful! All problem has been solved by carefully following this step-by-step instructions. Keep up the good work
WPBeginner Support
Glad you found our guide helpful!
Admin
John
Thanks very much. It was very veryhelpful.
WPBeginner Support
Glad our guide was helpful!
Admin
Michie
Your website is beneficial, especially to a beginner like me. Thank you so much
WPBeginner Support
Glad you found our guides helpful
Admin
Doy
Hi,
Thank you for this awesome website. I got this in the error log after adding this code.
[26-Apr-2022 02:45:31 UTC] PHP Warning: Use of undefined constant ‘WP_MEMORY_LIMIT’ – assumed ‘‘WP_MEMORY_LIMIT’’ (this will throw an Error in a future version of PHP) in /wp-config.php on line x
Is this a problem? Should I remove the code?
WPBeginner Support
That would only be an error for future versions of PHP. This solution should only be a temporary fix and your hosting provider should be able to assist with the root cause of the issue.
Admin
Alison Taylor
Thank you! You folks rock. This solved my problem. WPBeginner is my go-to website for learning new things about WordPress, even though I’m not a beginner.
WPBeginner Support
Glad our guide was helpful
Admin
J h
“Once you are done, you need to save your changes and upload your wp-config.php file back to your server.”
How again do you upload the file back to your server?
WPBeginner Support
You would need to use FTP or your host’s file manager again and there should be the option to upload and replace the file
Admin
Daniel
The changes are not having effects. We are still with 40MB and the site does not accept the changes. What should I do?
WPBeginner Support
As we state at the end of the article, if our recommendations do not work, please reach out to your hosting provider as they may have set a limit that would override what you as a user can set.
Admin
Liviu
Really worked.
I had white screen when I wanted to create a new post on PC browser. But worked on my phone.
Thanks
WPBeginner Support
You’re welcome
Admin
Simeon Adedokun
Thank you so much for this! It’s really helped me.
WPBeginner Support
Glad our guide could help
Admin
John Harries
Thank you for providing a straight forward solution to an error which occurred when I tried to update the php version from 7.1 to 7.4
Mart
Fantastic, thank you soooo much for this, simple straight talk.. excellent.. first problem solved … now got to learn more
WPBeginner Support
Glad our guide was able to help
Admin
Julian
I had to change mine to much higher and hope it won’t cause an issue? Changed to 1024M!
WPBeginner Support
It can mean the site can take longer to notice issues if some arise but shouldn’t cause a major issue in general.
Admin
Mujahid Siyal
I added the code problem is gone but a text “WP_MEMORY_LIMIT” has appeared in the top corner of logo. So what should I do about that?
WPBeginner Support
You would want to ensure you added the code snippet correctly as it is likely showing that code thinking it is text.
Admin
David
“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.”
Simple! What does that mean? It is gobbledegook to me.
WPBeginner Support
For using an FTP client we would recommend taking a look at our article below for a better understanding on the subject:
https://www.wpbeginner.com/showcase/6-best-ftp-clients-for-wordpress-users/
Admin
Anna yakub
This was super helpful for an issue I’ve battled with for a while now. Thanks so much
WPBeginner Support
Glad our recommendations were helpful
Admin
Katerina
I’m new in WordPress and I’m trying to figure out, for a couple of days, why suddenly I get an error 500 and can’t save my edits. This helped solve my problem. Thank you so much!
WPBeginner Support
Glad our guide could help
Admin
Richard Lamsdale
Thanks for this – it fixed my problem.
WPBeginner Support
Glad our guide was helpful
Admin
Malou
Helpful, Thank you so much
WPBeginner Support
You’re welcome
Admin
Segun
This worked perfectly for me. Thanks
WPBeginner Support
You’re welcome
Admin
Rick Richi
can I increase the memory to 512?
WPBeginner Support
You can certainly try to see if that fixes the error for you.
Admin
Haris imran
Thanks it helped me a lot
WPBeginner Support
Glad our guide was helpful
Admin
Arpita Hunka
This solution is not working for me, my website is hosted at AWS server and I have all the access, I have tried to set memory_limit in php.ini, wp-config and .htaccess. but still getting issue when accessing backend pages.
WPBeginner Support
You would want to reach out to the support for your hosting for what other options you have available with AWS
Admin
Anders
Thanks a lot….
A quick and easy fix!!
WPBeginner Support
You’re welcome, glad our guide was helpful
Admin
Faisal Arafin
You just saved me from heart attack…..
WPBeginner Support
Glad our guide could help
Admin
Laura
Thaaaanks, you save my day!
WPBeginner Support
You’re welcome
Admin
Benthe Kuijpers
Thanks so much! Was so worried when I had this fatal error, but this fix is just a piece of cake!
WPBeginner Support
Glad our guide was helpful
Admin
Dileepa K
Thank you for this post…
Very Helpful
WPBeginner Support
You’re welcome
Admin
Gunvant Nakum
Thanks you so much for your help
WPBeginner Support
You’re welcome
Admin
Sumit Gupta
This is not working for me.
WPBeginner Support
If our recommendations are not working, you would want to reach out to your hosting provider and they should be able to assist
Admin
Ademola Kayode Abdulai
this still works after few years,, Great thank you… works for me as well
WPBeginner Support
Glad our recommendation was helpful
Admin
Luuk
Great tip! Thank you very much!
WPBeginner Support
You’re welcome
Admin
Mehedi Mahmood
Thank you so so much! can’t really explain how helpful this was
WPBeginner Support
Glad our guide was helpful
Admin
Manthan Admane
Thank you so much.
Solved my issue
WPBeginner Support
Glad our guide was helpful
Admin
Mevlut Demiroz
Very thanks, fixed
WPBeginner Support
Glad our guide was helpful
Admin
Ivan
Hi, I had the memory exhausted message and I increased the wp memory limit to 12mb and it worked. Then a few days later I had the same error, so I had to increase the wp memory limit to 256mb and the message kept showing. I am currently on 1024mb, which seems excessive for a small website of 4 pages and a blog post of 15,000 words. Any suggestions how to resolve the issue or what might be causing it?
WPBeginner Support
You would want to reach out to your hosting provider and they can normally assist in finding the root of the issue for your specific site.
Admin
player
thank you so much.
WPBeginner Support
You’re welcome
Admin
Mathilda
thanks so much!
WPBeginner Support
You’re welcome
Admin
Sone Eric
Thank you very much. You solved my problem.
WPBeginner Support
Glad our article was able to assist
Admin