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

Fix: WordPress Memory Exhausted Error – Öka PHP-minnet

Att stöta på felet “tillåten minnesstorlek uttömd” i WordPress kan vara frustrerande. Det är ett vanligt problem som dyker upp när din webbplats behöver mer PHP-minne än vad som är tillåtet.

Det här felet kan göra din webbplats långsammare eller till och med krascha den tillfälligt. Det är därför det är viktigt att poprawka det snabbt för att din webbplats ska fungera smidigt för besökare.

Lyckligtvis finns det en enkel poprawka till detta problem. Genom att öka PHP-minnesgränsen kan du lösa detta fel och förbättra din webbplats prestanda.

I den här przewodniken går vi igenom de enkla stegen för att öka PHP-minnesgränsen och få din webbplats på rätt spår igen.

Fix: WordPress Memory Exhausted Error – Increase PHP Memory

Vad är WordPress Error om minne uttömt?

WordPress memory exhausted error är ett message som du kan se om din website har svårt att utföra sina uppgifter.

WordPress är built-in med PHP, ett programmeringsspråk på serversidan som behöver minne för att kunna run.

Precis som alla andra datorer har servrar WWW en begränsad mängd minne för att köra flera applikationer samtidigt. WordPress dostawca hostingu allokerar specifika minnesstorlekar till olika applikationer, inklusive PHP.

När din WordPress-kod är obligatorisk och kräver mer minne än vad som tilldelats som standard, visas detta message:

Fatalt fel: Tillåten minnesstorlek på 33554432 byte förbrukad (försökte allokera 2348617 byte) i /home4/xxx/public_html/wp-includes/plugin.php på rad xxx

Memory exhausted error displayed on a WordPress site

Din WordPress-webbplats kan ha förbrukat serverminnet om den har gjort det:

  • Många images, videoklipp och andra typer av media
  • Massor av oanvända tillägg till WordPress
  • Växte ur sina resurser för webbhotellets plan

Som standard försöker WordPress automatiskt att öka PHP:s minneslimit om den är mindre än 64 MB. Men 64 MB är ofta inte tillräckligt högt.

I nästa avsnitt visar vi dig hur du enkelt kan öka PHP-minnesgränsen i WordPress för att undvika felet “Memory exhausted”. Du kan använda snabblänkarna nedan för att navigera genom poradniken:

Note: Några av dessa metoder kräver att du direkt editerar dina WordPress-filer. Vi föreslår att du säkerhetskopierar din website först för att undvika att ytterligare error dyker upp på din website.

Är du redo? Låt oss hoppa in direkt!

Alternativ 1: Editera wp-config.php-filen

Först måste du redigera filen wp-config.php på din WordPress-webbplats. Detta är en av filerna i WordPress rdzeń som ligger i rotkatalogen, som vanligtvis heter public_html.

Du måste använda en FTP-klient som FileZilla eller filhanteraren i webbhotellets kontrollpanel.

Följaktligen måste du klistra in följande rad i wp-config.php-filen precis före den som säger, That's all, stop editing! Trevlig bloggning.

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

Den här koden säger till WordPress att öka limiten för PHP-minnet till 256 MB.

För mer information kan du se vår steg-för-steg przewodnik om hur du hittar och redigerar filen wp-config.php.

När du är klar måste du spara dina ändringar och ladda upp filen wp-config.php tillbaka till din server.

You can now visit your WordPress site, and the memory exhausted error should have disappeared.

Alternativ 2: Editera .htaccess-filen

Nästa metod är att editera .htaccess-filen. Denna fil är också placerad i WordPress-webbplatsens rotfolder.

Här måste du klistra in följande kod före raden där det står #END WORDPRESS.

php_value memory_limit 256M

På samma sätt som den tidigare koden kommer den att tala om för WordPress att öka PHP-minnesgränsen till 256 MB.

Därefter sparar du dina ändringar och uploadar filen tillbaka till din web server. You can now open your WordPress website again to see if the memory limit error has gone.

Om du inte kan hitta .htaccess-filen kan du läsa vår przewodnik om varför .htaccess-filen kan saknas och hur du hittar den.

Alternativ 3: Kontrollera din php.ini-fil

Om ovanstående metoder inte fungerar kanske du vill titta på din php.ini-fil.

php.ini är en fil som kontrollerar dina PHP-inställningar, inklusive PHP-versionen och PHP-skript. Det är inte en fil i WordPress rdzeń, eftersom din dostawca hostingu vanligtvis hanterar den.

Du kan kontrollera dess kod för att se din limit för minnesanvändning i PHP. För mer detaljer, kan du se vår guide om hur du hittar och editar php.ini-filen.

Men eftersom det här är en avancerad metod rekommenderar vi att du istället kontaktar supportteamet hos din hosting provider för att se om de kan öka WordPress memory limit manuellt. Annars kan detta leda till ytterligare error.

Du kan läsa vår guide om hur du på rätt sätt ber om support för WordPress för mer information.

Är du trött på att hantera WordPress-fel? Då kan du lämna stressen bakom dig och låta vårt expertteam ge dig snabb och pålitlig support i nödsituationer. Med vår on-demand-tjänst får du snabba poprawka utan krångel med löpande kontrakt. Ring vårt team för akut WordPress-support nu!

Alternativ 4: Upgrading to your WordPress webbhotell

Om du ständigt stöter på felet “Memory exhausted” kan det vara ett tecken på att din webbplats har vuxit ur sin nuvarande hostingplan.

När din webbplats lockar fler besökare och lägger till mer innehåll krävs det mer resurser för att den ska fungera smidigt. Att uppgradera en plan med en högre minnesallokering kan vara en trwale lösning.

Överväg att uppgradera ditt WordPress webbhotell om:

  • Du har försökt med de tidigare lösningarna, men felet kvarstår.
  • Your website har ökat betydligt i trafik eller content.
  • You plan to add features or functionality that require more resources.

Bluehost erbjuder prisvärda och tillförlitliga WordPress webbhotell planer som kan skala med din webbplats behov. De tillhandahåller en användarvänlig plattform som är särskilt optimerad för WordPress, vilket gör det enkelt att hantera din website.

Om du använder vår Bluehost coupon code, då kan du få upp till 61% rabatt på ditt första köp. Klicka bara på knappen under för att få det:

Bluehost

Så här undviker du att trötta ut ditt minne i WordPress

Nu när du har fixat WordPress error med uttömt minne, följer här några proaktiva steg för att förhindra att det händer igen:

  • Deactivate oanvända tillägg. Många tillägg bidrar till minnesanvändningen. Se regelbundet över dina installerade tillägg och deaktivera dem som du ej aktivt använder för att gratis frigöra minne för viktiga uppgifter.
  • Optimera images. Stora images kan sluka mycket minne. Överväg att använda ett plugin som EWWW Image Optimizer för att automatiskt komprimera images innan du uppladar dem till din site.
  • Använd ett plugin för caching. Tillägg för caching lagrar data på webbplatsen, vilket minskar behovet av att WordPress återskapar den vid varje besök. Detta kan avsevärt förbättra website-prestandan och minska minnesanvändningen.

Vi hoppas att den här artikeln hjälpte dig att lösa felet WordPress-minne uttömt genom att öka PHP-minnesgränsen. Du kanske också vill se vår steg-för-steg przewodnik för nybörjare om felsökning av WordPress-fel och vår expertlista över de vanligaste WordPress-felen.

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. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

463 kommentarerLeave a Reply

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

  2. 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.

  3. 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.

  4. 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.

  5. 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.

    • 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

  6. 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

    • 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

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

    • 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

  8. Thank you, this was helpful! All problem has been solved by carefully following this step-by-step instructions. Keep up the good work :)

  9. 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?

    • 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

  10. 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.

  11. “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?

    • 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

  12. The changes are not having effects. We are still with 40MB and the site does not accept the changes. What should I do?

    • 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

  13. Really worked.

    I had white screen when I wanted to create a new post on PC browser. But worked on my phone.

    Thanks

  14. 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

  15. Fantastic, thank you soooo much for this, simple straight talk.. excellent.. first problem solved … now got to learn more

    • It can mean the site can take longer to notice issues if some arise but shouldn’t cause a major issue in general.

      Admin

  16. 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?

    • You would want to ensure you added the code snippet correctly as it is likely showing that code thinking it is text.

      Admin

  17. “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.

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

  19. 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.

    • You would want to reach out to the support for your hosting for what other options you have available with AWS

      Admin

  20. Thanks so much! Was so worried when I had this fatal error, but this fix is just a piece of cake! :-)

    • If our recommendations are not working, you would want to reach out to your hosting provider and they should be able to assist

      Admin

  21. 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?

    • 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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.