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

Correção: Erro de memória esgotada do WordPress – Aumente a memória do PHP

Nota editorial: Ganhamos uma comissão de links de parceiros no WPBeginner. As comissões não afetam as opiniões ou avaliações de nossos editores. Saiba mais sobre Processo editorial.

Você vê uma mensagem de erro de tamanho de memória permitido esgotado no WordPress?

Esse é um dos erros mais comuns do WordPress, e você pode corrigi-lo facilmente aumentando o limite de memória do PHP no WordPress.

Neste artigo, mostraremos a você como corrigir o erro de memória esgotada do WordPress aumentando o limite de memória do PHP.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

O que é o erro de memória esgotada do WordPress?

O erro de memória esgotada do WordPress é uma mensagem que você pode ver se o seu site estiver com dificuldades para executar tarefas.

O WordPress foi criado usando PHP, uma linguagem de programação do lado do servidor que precisa de memória para ser executada.

Assim como qualquer outro computador, os servidores da Web têm uma quantidade limitada de memória para executar vários aplicativos ao mesmo tempo. Os provedores de hospedagem do WordPress alocam tamanhos específicos de memória para diferentes aplicativos, inclusive o PHP.

Quando o código do WordPress exigir mais memória do que a memória alocada por padrão, você verá essa mensagem de erro:

Erro fatal: Tamanho de memória permitido de 33554432 bytes esgotado (tentou alocar 2348617 bytes) em /home4/xxx/public_html/wp-includes/plugin.php na linha xxx

Memory exhausted error displayed on a WordPress site

Seu site WordPress pode estar esgotando a memória do servidor, se estiver:

  • Muitas imagens, vídeos e outros tipos de mídia
  • Muitos plug-ins do WordPress não utilizados
  • Excedeu os recursos de seu plano de hospedagem

Por padrão, o WordPress tenta automaticamente aumentar o limite de memória do PHP se ele for inferior a 64 MB. No entanto, 64 MB geralmente não é suficiente.

Dito isso, vamos ver como aumentar facilmente o limite de memória do PHP no WordPress para evitar o erro de memória esgotada.

Você pode usar os links rápidos abaixo para navegar pelo tutorial:

Observação: alguns desses métodos exigem que você edite diretamente os arquivos do WordPress. Sugerimos fazer o backup de seu site primeiro para evitar que outros erros apareçam em seu site.

Opção 1: editar o arquivo wp-config.php

Primeiro, você precisa editar o arquivo wp-config.php em seu site do WordPress. Esse é um dos principais arquivos do WordPress, localizado no diretório raiz, geralmente chamado public_html.

Será necessário usar um cliente FTP como o FileZilla ou o gerenciador de arquivos no painel de controle da sua hospedagem na Web.

Em seguida, você precisa colar a seguinte linha no arquivo wp-config.php, logo antes daquela que diz: That's all, stop editing! Feliz blog.

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

Esse código informa ao WordPress para aumentar o limite de memória do PHP para 256 MB.

Para obter mais detalhes, consulte nosso guia passo a passo sobre como localizar e editar o arquivo wp-config.php.

Quando terminar, salve as alterações e carregue o arquivo wp-config.php de volta para o servidor.

Agora você pode acessar o site do WordPress, e o erro de memória esgotada deve ter desaparecido.

Opção 2: editar o arquivo .htaccess

O próximo método é editar o arquivo .htaccess. Esse arquivo também está localizado na pasta raiz do site do WordPress.

Aqui, você precisa colar o seguinte código antes da linha que diz #END WORDPRESS.

php_value memory_limit 256M

Semelhante ao código anterior, ele dirá ao WordPress para aumentar o limite de memória do PHP para 256 MB.

Depois disso, basta salvar as alterações e carregar o arquivo de volta no servidor da Web. Agora, você pode abrir o site do WordPress novamente para ver se o erro de limite de memória foi eliminado.

Se você não conseguir encontrar o arquivo .htaccess, consulte nosso guia sobre por que o arquivo .htaccess pode estar ausente e como encontrá-lo.

Opção 3: Verificar o arquivo php.ini

Se os métodos acima não funcionarem, talvez seja necessário examinar o arquivo php.ini.

O php.ini é um arquivo que controla suas configurações de PHP, incluindo a versão do PHP e os scripts PHP. Não é um arquivo central do WordPress, pois seu provedor de hospedagem geralmente o gerencia.

Você pode verificar seu código para ver o limite de uso de memória do PHP. Para obter mais detalhes, consulte nosso guia sobre como localizar e editar o arquivo php.ini.

No entanto, como esse é um método avançado, recomendamos entrar em contato com a equipe de suporte do seu provedor de hospedagem na Web para ver se eles podem aumentar o limite de memória do WordPress manualmente. Caso contrário, isso pode resultar em mais erros.

Para obter mais informações, leia nosso guia sobre como solicitar corretamente o suporte do WordPress.

Opção 4: Atualizar sua hospedagem do WordPress

Se você estiver encontrando constantemente o erro de memória esgotada, isso pode ser um sinal de que seu site ultrapassou o plano de hospedagem atual.

À medida que seu site atrai mais visitantes e adiciona mais conteúdo, ele requer mais recursos para funcionar sem problemas. A atualização para um plano com uma alocação de memória maior pode ser uma solução permanente.

Considere a possibilidade de atualizar sua hospedagem do WordPress se:

  • Você tentou as soluções anteriores e o erro persiste.
  • Seu site cresceu significativamente em termos de tráfego ou conteúdo.
  • Você planeja adicionar recursos ou funcionalidades que exigem mais recursos.

A Bluehost oferece planos de hospedagem WordPress acessíveis e confiáveis que podem ser dimensionados de acordo com as necessidades do seu site. Eles fornecem uma plataforma fácil de usar, otimizada especificamente para o WordPress, facilitando o gerenciamento do seu site.

Se você usar nosso código de cupom Bluehost, poderá obter até 61% de desconto em sua primeira compra. Basta clicar no botão abaixo para obtê-lo:

Bluehost offer for WPBeginner readers

Como evitar o esgotamento de sua memória do WordPress

Agora que você corrigiu o erro de esgotamento de memória do WordPress, aqui estão algumas etapas proativas para evitar que isso ocorra novamente:

  • Desative os plug-ins não utilizados. Muitos plug-ins contribuem para o uso da memória. Analise regularmente os plug-ins instalados e desative os que não estiver usando ativamente para liberar memória para tarefas essenciais.
  • Otimize as imagens. Imagens grandes podem consumir muita memória. Considere a possibilidade de usar um plug-in como o EWWW Image Optimizer para compactar automaticamente as imagens antes de carregá-las em seu site.
  • Use um plug-in de cache. Os plug-ins de cache armazenam os dados do site, reduzindo a necessidade de o WordPress gerá-los novamente a cada visita. Isso pode melhorar significativamente o desempenho do site e reduzir o uso da memória.

Esperamos que este artigo tenha ajudado você a resolver o erro de memória esgotada do WordPress aumentando o limite de memória do PHP. Talvez você também queira ver nosso guia passo a passo para iniciantes sobre como solucionar erros do WordPress e nossas escolhas de especialistas sobre os melhores plug-ins do WordPress para expandir seu site.

Se você gostou deste artigo, inscreva-se em nosso canal do YouTube para receber tutoriais em vídeo sobre o WordPress. Você também pode nos encontrar no Twitter e no Facebook.

Divulgação: Nosso conteúdo é apoiado pelo leitor. Isso significa que, se você clicar em alguns de nossos links, poderemos receber uma comissão. Veja como o WPBeginner é financiado, por que isso é importante e como você pode nos apoiar. Aqui está nosso processo editorial.

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.

O kit de ferramentas definitivo WordPress

Obtenha acesso GRATUITO ao nosso kit de ferramentas - uma coleção de produtos e recursos relacionados ao WordPress que todo profissional deve ter!

Reader Interactions

464 ComentáriosDeixe uma resposta

  1. Syed Balkhi says

    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. Vennh says

    This Worked for me.

    /**This is a test for memory*/
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    Thank you for this wonderful share.

  3. Lu says

    Should the memory limit ever be higher than 64M? Most WP sites i’ve worked on the average page load never exceeds 40-5megs. The reason I ask, is I read that the WP_MEMORY_LIMIT defines the amount of memory WordPress can use per Apache thread. Which means that multiple threads will use more and more, and eventually swap to disk which is never good.

    Anybody an expert and can answer this?

  4. WPBeginner Staff says

    It seems like WordPress is either unable to create wp-config.php file or the file gets deleted after the install. Use ftp to make sure that there is a wp-config.php file present on your site. If not then try creating one by renaming the wp-config-sample.php file to wp-config.php file. You will need to manually edit the file and provide your database information.

      • aiyeboy says

        if i locate it on an ftp, and i click on it, it brings it like a download file, pls help with a full guide on how to do it pls my site is going down everyday…

        • tony leon says

          don’t double click it. Either right click and select EDIT or highlight it and look for an EDIT button somewhere (maybe at the top if it’s Godaddy). Good Luck!

  5. LJ LaValle says

    I opened the wp-config.php file from my ftp directory.
    I was not sure how to completely enter the adjustment – I didn’t know basic coding for php, so I just copied the basic precursors shown for each entry and added as follows:

    /**This is a test for memory*/
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    It worked!

  6. Doug says

    Thank you!!! This fixed a problem I created myself and saved having to pay someone at the hosting company to update the file.

  7. kim says

    I am getting this exact error but I am not sure how to get into do I get into wp-config.php which is located in the root WordPress directory as I don’t know where to find it. Yes I am a complete beginner. Can you help?

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 122880 bytes) in /home/crooked1/public_html/wp-includes/SimplePie/Sanitize.php on line 331

  8. mike .levine says

    Thank you so much!! For real.. you have been a lifesaver. I can’t tell you how appreciative I am for your help.

  9. Timothy says

    Hi,

    I’ve tried to increase the limit to 64mb, and I got this warning until 5 times:

    ‘WARNING: Job restart due to inactivity for more than 5 minutes.’

    The database backup is stopped until 60s%, and the result is below when it tried to upload to Dropbox:

    ‘ERROR: Uploaded file size and local file size don’t match.’

    What’s wrong with it? I’m using Bluehost.

    Thanks!

    PS: I’m not a technical person, so give explanation in details :-)

  10. Thomas Cole says

    Been having a doozy of a time working on my site and I would sacrifice a MacBook at midnight to get my site working, one little line of code and we are back up. Thanks!

  11. Jonni says

    Thank you so much!!!!
    I’m in the middle of a launch and all of a sudden I couldn’t update or create any web pages on the whole site because of a 500 Internal Server Error. (And of course this happened as soon as I discovered the Home page had a big problem.)

    Could get no help from support, am not a web developer.

    Yet I was STILL able to follow your instructions and Hallelujah! Miracle of Miracles! Everything works now.

    All this work driving traffic, getting new people to the site – almost wasted due to server error – but Disaster Averted! you saved the day.

    My sincerest gratitude.

    Again, can’t thank you enough.

  12. Casey Friday says

    Thanks so much! I was about to bitch to WooThemes that their $129 extension was breaking my site, but it turned out to be a memory issue. Cheers!

  13. Adrian says

    On line 36/37 of wordpress, wp-config.php you must type:

    /** Memory Limit */
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    For me this problem is solve thi way. You can change 64M with what value you want.

    • Adam Singer says

      This comment is sooo key!

      You have to add define( ‘WP_MEMORY_LIMIT’, ’64M’ ); just before the unique key and salts are defined, otherwise the change doesn’t take effect. Thanks!!!

      • omniafausta says

        yesssss thanks, I was wondering why it didn’t work for me. It was because so far no one told me WHERE in the wp-config i had to add this line. THANKS!!!

  14. Titel says

    Hello,
    Today I had a problem with wordpress: after I logged appeared “white screen of death”. We went into cpanel and inserted “define (‘WP_MEMORY_LIMIT’, ’64M ‘)’ in wp-config.php and everything went very well.
    Thanks a lot WPBeginner.

  15. Hamza Ahmed says

    Thanks a lot, i work very hard with every method i found on internet, but i filled , my problem occur during word-press installation i pasted this code in mid and increase its value to 128 mb , now its works fine, thanks a lot again.

  16. Jeff Danforth says

    My host provides 64MB, and wants a hefty kicker to increase the php memory limit – so I’m inclined to be “green” and reduce my memory use.

    HOW might I determine what plugins or other things to remove to stay under 64MB
    A) php memory consumption, e.g. which plugins are being greedy
    B) have I got a memory leak issue, e.g. any plugins being nasty

    Thank you for this forum, by the way – I am truly a beginner, but excited about WP (grrr, if I can make it jump its hoops right)

  17. Daniel says

    Didn’t work for me, but I’m not sure what it means to be “inside the main php tag”. I opened the file in Dreamweaver and did a search. The word “main” doesn’t appear anywhere on the page. So I put the code in line 2, just after the “<php". Tried it at 64 and 128. Thanks.

  18. Deepanshu says

    Thanks for the help.
    But 64M was already default for me and of course it wasn’t sufficient so I changed it to 96M and I think u should mention this as well.

  19. Jan says

    Nice but nothing works – use rackspace cloud – tried 32 – 64 – 128 – 256- 512 – 1024Mb MU site i can’t go more up and only in admin i can’t get access after a plugin from wpmudev so guess i have to delete that and try something pro.

  20. pathik says

    its really work,, i had problem of internam server,,, when add new plugine,,, i just increse memomry limit
    define(‘WP_MEMORY_LIMIT’, ’64M’);
    in wp-admin and problem solved..

    tthnaks a lot

  21. Joke van de Fliert says

    thanks! for me the provider had to change a setting to increase the memory limit, but that did fix it!

  22. Jennifer Ortiz says

    Thanks a million for this! I got the error message right after the WordPress install–I never even had a chance to add a plug-in.:

    Fatal error: Allowed memory size of 33554432 bytes exhausted…

    All seems to be working fine now.

  23. Timothy Jacobs says

    I have tried to do this, but it has not solved the problem.  I am on 1&1 hosting and I have tried all the changes, but I still get this error whenever uploading a semi-large picture:
     
    Fatal error: Out of memory (allocated 29884416) (tried to allocate 4096 bytes) in /homepages/21/d258522816/htdocs/TBJFilms/WP/wp-includes/media.php on line 1010
     
    What is your suggestion?

  24. aidilgoh says

    Tried placing this at the end of the wp-config.php and didnt work.

    However, placing it on top right after the <?php tag worked. Hooray!

    • Ahmad Zaruq Spain says

      Yes, I used the
      1error_reporting(E_ALL); ini_set(‘display_errors’, 1);
      2
      3define( ‘WP_DEBUG’, true);I found in a post next to this one and was getting an error by using define(‘WP_MEMORY_LIMIT’, ‘128M’); on the last line of my php-config file. Thanks to this comment I placed it right below <?php tag at the top and now the error report is no longer :) I just hope my site doesn't keep crashing on every new plugin install, going to check that now. Thanks to all you geeks out there!

  25. PatrickTyrus says

    this was a great help, but as you noted it could easily be a plugin, or as someone mentioned it could be a memory leak.

    And as others have pointed out, there are memory settings for a reason, some hosts will cut your services if you try to circumvent them.

    Is there a way to check on what’s eating memory?

    I’ll be searching, but this is something that should be listed under related posts, or as a note and link at the end regarding one of the “numerous solutions for it”. Going for the “simplest one” might get you through the day, but is may not be a good long term solution as it may cover up the real problem and delay the inevitable.

    • Alexis O'Neill says

      Worked for me!! I changed my site language to Spanish and I guess that used up the memory. Added the simple line recommended in the post and voilá!! Back in my admin mode. The really helpful part was “Don’t panic!” because my anxiety level was rising fast.
      Thanks ever so much.

  26. wpbeginner says

    @shally1584 There is no = << in our code. So are you sure that you are pasting our code as an independent function and not as part of something else.

  27. shally1584 says

    hi.i tried to adjust memory limit and got this error

    ‘Parse error: syntax error, unexpected ‘=’ in /home/amanerdm/public_html/beaverealty.com/wp-config.php on line 62′

    pls help fix this.thanx.

  28. Luna says

    Thank you for this post… I had a couple of category / archive query pages that were throwing this error after I upgraded to WordPress 3.1. I was just about to re-write the queries until I found your post in a Google search.

    You saved me a lot of work and headaches :)

  29. Kdb says

    I ended up having to switch hosting companies because I couldn’t get my current one to increase the memory from 32MB to, well, anything more. Pretty sad. Took a bit of hassle to transfer three WordPress sites (and multiple other sites), but it was worth it. My current host offers 128MB and my sites are working SO much better. I can actually add plug-ins.

  30. Richard says

    Hello
    I tried the fix by adding the line immediately after the opening >php tag (line 1)
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    It did not work for me BUT
    I placed the line with comments for my own use on (as it happens) line 22 and it worked.

    I am testing this procedure on a test WP site using Twentyten 1.2 Theme

    /home/par*****/public_html/wp-config.php

    Line 22 /** WP memory limit Note it does not work when placed immediately after line 1 */
    define(‘WP_MEMORY_LIMIT’, ’64M’);

  31. Chris says

    This trick doesn’t work for me ever since WP 3.

    what I found worked was to create a PHP.INI file in the wp-admin folder with the line:

    memory_limit = 128M

    (or whatever you want to make it)

  32. kdb says

    I tried this, but my host limits it to 32 megs. Can anyone recommend a good host for WP, because I’m going to have to change. Thanks!

  33. Seth Merrick says

    Great article. A brand new plugin that may soon find its way on to this list is Cobalt WP Boost.

    Check it out here:
    http://frugaltheme.com/about/cobalt-wp-boost-plugin/

    It allows blog owners to raise their WordPress Memory Limits with a couple of mouse clicks, as well as showing at-a-glance memory usage information. WordPress keeps its internal memory limit at 32MB, which is fine for a small-time blog; but if you’re trying to add any robust plugins for social networking or ecommerce applications, 32M will not suffice. This problem can only be expected to worsen with the release of 3.0 which, judging from the beta release, will consume a lot more memory itself without upping the 32MB limit.

  34. W^L+ says

    Just remember that if the problem is a memory leak (either in PHP itself or in some library that is used by a plugin), this will merely delay the occurence.

    Before you change the memory limits, you should ensure that you’re using the most up-to-date versions of any plugins. Be sure you are running the newest version of WP. If your host offers multiple versions of PHP, be sure you’re using version 5.

    Your hosting service may have preset limits on memory usage. If your editing causes you to exceed those limits, your service may be suspended or canceled without warning.

  35. wparena says

    I think the better way is to put this limit in wp-setting.php file where this memory limit already described as 32M, just changed that value to 64M.

  36. Chad McCullough says

    I think that this might fix an issue I’ve been having with my site. I just can’t figure out where the main php table is in the wp-confip.php to place the line.

    Thanks!

Deixe uma resposta

Obrigado por deixar um comentário. Lembre-se de que todos os comentários são moderados de acordo com nossos política de comentários, e seu endereço de e-mail NÃO será publicado. NÃO use palavras-chave no campo do nome. Vamos ter uma conversa pessoal e significativa.