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.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

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.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

463 kommentarerLämna ett svar

  1. Vennh

    This Worked for me.

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

    Thank you for this wonderful share.

  2. joey

    Thanks for the great and simple help! This solved my issue ! ;) Thumbs up;)

  3. Lu

    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

    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.

  5. aiyeboy

    hope i wont be mocked, where do i see the config.php, is it in my phpmyadmin or where pls

      • aiyeboy

        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

          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!

  6. LJ LaValle

    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!

  7. Ali

    how about i change it to 256 m

  8. Doug

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

  9. kim

    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

  10. mike .levine

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

  11. Timothy

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

  12. Thomas Cole

    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!

  13. Domestic Herald

    THANK YOU so much!!!! This worked like a charm and took me less than a minute to implement.

  14. Jonni

    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.

  15. bungkelip

    I add define(’WP_MEMORY_LIMIT’, ’1024M’); but its not work, help me

  16. Casey Friday

    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!

  17. Janelle

    Thanks a million! This is so useful, and more people should see this post.

  18. Adrian

    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

      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

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

    • Rosie Taylor

      Thank you for clarifying this step. Now I know why it never just changing the other line for the value didn’t work before. This saved me big time for a client tonight!

  19. Titel

    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.

  20. Hamza Ahmed

    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.

  21. Jeff Danforth

    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)

  22. Matthew

    This worked for me, thanks for the tip!

  23. Daniel

    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.

    • Editorial Staff

      The main php tag means just insert it like you did. Sometimes this doesn’t work in which case you have to ask your host.

      Administratör

  24. Deepanshu

    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.

  25. Jan

    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.

  26. Julie Geiger

    worked perfect.. thank you for sharing, tried a few other fixes but all errored out.

  27. Nick

    Thank you for the article. It was a great help

  28. pathik

    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

  29. Joke van de Fliert

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

  30. Jennifer Ortiz

    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.

  31. Timothy Jacobs

    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?

    • wpbeginner

       @Timothy Jacobs Contact your host. If they refuse to help, then switch.

  32. aidilgoh

    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!

    • Guy

      Exactly !! thanks a lot – made my day !

    • Appdunia

      Worked for me only after placing just after php tag. Thanks a lot !

    • Ahmad Zaruq Spain

      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!

  33. PatrickTyrus

    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

      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.

    • Kiu Karakas

      define(’WP_MEMORY_LIMIT’, ’64M’);
      not solved
      define(’WP_MEMORY_LIMIT’, ’164M’);
      solved
      THANKS

  34. wpbeginner

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

  35. shally1584

    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.

  36. Luna

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

  37. Kdb

    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.

  38. Richard

    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’);

  39. Chris

    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)

    • Editorial Staff

      Sounds like a host issue rather than WP 3.0 issue. We still have this trick working on our clients.

      Administratör

      • Trunks

        This worked for me! Thanks!!!

        Create PHP.INI in the wp-admin folder, with the line ”memory_limit = 128M;”

        I changed all the other methods, and this was the only one that seemed to work.

        • Don

          Thanks. This worked for me! Nothing else worked until I read your comment. Website host was not overly helpful.

    • dan

      Brilliant! Thanks!

  40. kdb

    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!

    • Editorial Staff

      Look through our list of recommended hosts. You can find it on our homepage.

      Administratör

  41. phil

    I put that line at the very top of the file (wp-config.php) and it worked!

  42. ayahshiva

    i also got the same warning when i activated too many plugin

  43. Eyl

    I have done the trick but seems like nothing happened. The error keep showing so can you suggest other solutions?

    • Editorial Staff

      On some hosts, this trick won’t work. So you have to ask (beg) them to increase the PHP Memory Limit. OR get rid of the plugin which is causing it.

      Administratör

  44. Seth Merrick

    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.

    • Chad McCullough

      I just downloaded the plug-in and I’ll give it a try on my test site. Thanks.

  45. W^L+

    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.

    • Dunn

      I tried to deactivate the plugins one by one and found out that the Google XML Sitemaps plugin cause problem.

  46. wparena

    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.

    • Chad McCullough

      Thank you, wparena. I’ll try this.

    • Chad McCullough

      Changing the settings in the wp-settings.php file fixed my 2 week, driving me crazy, issue! Thank you very much!!

      -Chad

    • Editorial Staff

      Yes, but editing the core files is not the best way. You would have to change that every time you update WordPress. The way we share in this article, will save you time.

      Administratör

      • Chad McCullough

        I would much rather not modify core files, if possible. Where would I place the line in the wp-config.php file? I’m not sure where the main php table is.

        Thanks for the article and the help!

        • Chad McCullough

          That worked. Thanks!

  47. Kate Mag

    Awesome trick. Is that same with PHP memory limit?

  48. Chad McCullough

    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!

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.