Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Correggi: Errore WordPress Memory Exhausted – Aumentare la memoria PHP

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.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

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

Memory exhausted error displayed on a WordPress site

È 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:

Bluehost offer for WPBeginner readers

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:

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.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

464 commentiLascia una risposta

  1. 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!

  2. Michelle

    It’s 1:53AM and because of you, I can sleep in peace now. THANK YOU!

  3. Chintan Dave

    define( ‘WP_MEMORY_LIMIT’, ‘256M’ ); worked all time. Thank a lot for the solution.

  4. mohammed

    you guys are amazing you solved most of the issues i encounter since started working with WordPress.

  5. Siddhartha Gautam

    It worked for me. Thanks!

  6. Haley McCalister

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 22 bytes) in /home/nels1max/public_html/ngifts/wp-includes/class-wp-hook.php on line 286

    I’ve tried to expand my limit but it didn’t work. When I refresh the page, it changes what’s after “/wp-includes/” and the line number, but none of those files have a place to expand the size. Any tips?

    • Jordan Casey

      Try increasing it to 512M. There still isn’t enough memory for whatever theme you’re running. Good luck! P.S. make sure that you have more than 512M of memory. Ask your hosting provider.

  7. Marcel Dusek

    Great! It worked. Thank you so much !!!

  8. Vikas Yadav

    Thank you so much for sharing this. Helped me a lot!

  9. Ian

    It works! Thanks for the suggestion. But I have a question. I find another article said that changes WP_MEMORY_LIMIT in default-constants.php. Is there any different between this two methods?

    • Jeff C

      I have the same question. Can you explain the difference? Why use one over the other?

      • WPBeginner Support

        The constants file is for settings that don’t change, editing the config file is where you would make changes that can be reverted later when you are no longer receiving the error.

        Admin

  10. Joseph Sintum

    Thank you very much for this fix.
    I was already freaking out…

  11. Ahad Arzi

    Thanks man. iT’S REALLY HELPS

  12. Heather

    Wow, this worked like a charm and it was easy peasy! Thanks so much!

  13. Peter

    Thank you very much! It works :)

  14. Jane

    I looked everywhere for a solution and even called the host searching for an answer. Fixed it PERFECTLY! Thanks so very much!

  15. Ton

    Thanks a lot! My problem was solved in 5 minutes!!

  16. kartik

    Dear All,

    we are getting this error
    let me know the solution on it?

    Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 8192 bytes) in /home/f036v20tz3th/public_html/wp-includes/functions.php on line 5276

    Regards
    KARTIK

  17. Desmond Lai

    Great! It works well. Thank you so much.

  18. Richie

    Thanks for the tips, fixed with the memory line in wp-config

  19. Shehan Disanayake

    This was very helpful. Thanks a lot.

  20. Jaime

    Thanks so much guys for this article! What is the diference from changing wp_memory_limit (wp-config.php) and memory_limit (php.ini)??? Are the same??
    This memory limit is for individual sessions or entire wordpress site?? I ask because if i had 200 visitors in minutes.. i have to go damn higher with this number?? Or try to keep it low??? Hope you can help me with this!

  21. Alexander

    Thank you so much!!!

  22. Jeremy

    Thank you guys so much for this! I spent the last couple hours trying to figure this out.

    Thanks again!

  23. Rick Hunter

    Excellent. Thanks so much. Changed to 1024 and it worked like a charm.

  24. Ujenk

    When I changed with 512 M it was failed then I put it define( ‘WP_MEMORY_LIMIT’, ‘2000M’ );
    And it works well.
    /* That’s all, stop editing! Happy blogging. */ :-)

  25. Joshua

    if that code doesn’t work, rephrase it to

    //increase WP Memory Limit
    define(‘WP_MEMORY_LIMIT’, ‘256M’);

  26. Pascal

    Could this be set to 512MB by any chance?
    I am hosted by OVH

    Thank you!

    • suraj

      worked like a charm and loads faster .. but sure would like to knw the root cause and fix the issue there

    • suraj

      you can change but it maxed out the memory and gave frequent errors of the same, editing posts on wordpress.com also had errors and tags and categories did not populate there.
      in WP it seems to work but it lagged considerably.
      If you have more memory allocated then you can do it. I am gonna do half of memory allocated by hosting. check cpanel for that.

  27. Dee

    Thank you so much! I’ve been waiting for my developer to respond in order to fix it when I could have just done it myself! So much time wasted, thank you for publishing this!!

  28. Brent

    Thanks, you da MAN! Fixed my problem

  29. Yakin Shah

    This is awesome. just 2minutes, and I got my website back to working. Thanks!

  30. Krista

    You ROCK! Easy to follow and it worked! I am web-illiterate and was able to fix it in one go. THANK YOU!

  31. Silvero

    Awesome, thank you, you saved my site :D

  32. Thiago

    You guys are great. Thank you so much for the help!
    It worked!

  33. Sue Hanson

    Thanks a lot for this article. It really helped me out. I was able to fix this problem and get onto building my site.

  34. Lulu

    Beautiful, simple fix, thanks so much!!

  35. Morgan Leahy

    Before doing any of this…be sure to check your root install directory. I had a blank ‘index.htm’ file that was left by my hosting service, and I completely overlooked it.

  36. Jill

    Thank you so much for posting this tutorial! It fixed my website so I could start breathing again!

  37. zac

    Worked like a charm… Love the internet!

  38. Dana Jewel

    Thank you so very, very much for sharing this tip.

  39. Bharat M

    You are rocking men…

    Every time I got an problem, I got it solution from here…

    Thanks for the awesome article.

  40. Karen Gusler

    Thank you!!!! This was a Godsend!!! While trying to troubleshoot why some emails are not being sent via our online form, I installed a plugin and it caused this error. My web site is back up and running!!!! Thank you again!

  41. Renske

    By following these steps I have fixed the problem. Thank you SOOOOO much!

  42. Enzo

    Excuse me. What could be the cause of this?

  43. Jason Didner

    That fixed a number of problems! Being able to change themes; being able to save my widgets – great tip! Spent a lot of time looking for this solution.

  44. Keshav

    Thanks a lot!
    It works really nice for me.
    Thank you so much.

  45. Amir Khan

    Thanks a lot fixed my issue Successfully

  46. aisha

    this doesn’t resolve my issue :( plz now tell me what I can do ?
    still error is there

    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4114136611 bytes) in C:\xampp\…\wp-includes\functions.php on line 5163

    • Joel

      I get this error quite often. And I am not sure why.

      It comes from the function wp_is_stream(). I’m not sure where this is being used that is causing the error.

      A bit of investigation showed that if you comment out wp_head() in your header.php file that solves the issue. More specifically, it is something hooked onto the ‘wp_head’ action, and I think one of the filters with priority of 10. Unfortunately, after getting this far, the error magically fixed itself and went away, so I wasn’t able to track down the exact function. Also, wp_is_stream() was only used in 3 or 4 places, so maybe you could find the culprit easier just by checking the usages of that function.

  47. Brandon J

    This was amazing. I was skeptical at first since this was my first time ever doing something like this. I finally just went for it and it worked. Thank you so much.

  48. Sahil gour

    Thank you so much for explaining everything. it works thanks

  49. Sirisha

    This fixed my issue. Thank you for the well-explained article.

  50. Shriram

    Thanks a lot, you saved me. You are my go-to site for most of my wordpress related problems!

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.