Problem z ” PHP Fatal Error: Out Of Memory ” – Aktualizacja wordpress


Zaskoczył mnie dzisiaj problem z aktualizacją wordspressa na jednym z moich serwisów, a konkretniej na serwisie e-matma24.pl. Problem ? – Podczas próby aktualizacji wyskakuje okno z problemem  :

 PHP Fatal error: Out of memory (allocated 49545216) (tried to allocate 77824 bytes) in /home/xxxxx/public_html/xyz/admin.php(1758) on line 40

Ciężko znaleźć coś w sieci na ten temat, jednak odnalazłem kilka stron anglojęzycznych, które podawały możliwości. Jeden z racji możliwości wypróbowałem. Hosting na którym stoi strona to dość popularny 1and1.pl , oczywiście darmowa wersja, więc istnieje możliwość iż oni mnie ograniczają.

Oki, a teraz co próbowałem zrobić, dodałem  do pliku wp-config.php taką oto linijke :

define(’WP_MEMORY_LIMIT’, ’32M’);

Niestety nie pomogło, i nie mam pojęcia jak rozwiązać problem, może jakaś osoba trafii tutaj i rozwiażemy problem razem. 🙂

Problem został już opisane na stronie. Zamieszczam poniżej tekst, bo wiadomo jak to jest ze znikającymi stronami.

 

Last night when I was moderating some comments on TechPP, I was shocked to see an error page instead of the admin panel dashboard. The error read something like this –

PHP Fatal error: Out of memory (allocated 49545216) (tried to allocate 77824 bytes) in /home/xxxxx/public_html/xyz/admin.php(1758) on line 40

The first thing I could think of was to restart the Apache httpd service. This immediately solved the issue. but I knew this is not a permanent fix for the issue. When I researched further, I got to know that the error comes when certain PHP scripts require more memory than PHP was allowed by default.

So the solution is to increase the memory allocated for PHP. How to do that? There are 4 possible ways –

1. Try looking for the php.ini file. You might find some redundant php.ini files, so make sure you have got the one which is actually being read by PHP. o be sure, create a new php file in your root folder, say “check.php” and have phpInfo(); within the php open and close tags. Execute this file to get the information on where the php.ini is residing. Normally it will be in /usr/local/lib/php.ini

Open the php.ini file in a text editor like TextPad (not in Notepad) and change the values for memory_limit. By default you should see memory_limit = 8M. Try changing it to 12M. If it doesn’t work, increase it to 16M or even 24M and so on.

2. In case you can’t find the php.ini file or do not have access to it, then open up the file which was throwing the error (admin.php in my case) and add a line below just after ini_set(’memory_limit’, ‘12M’);

3. You can even consider adding a line in .htaccess file which will resolve the issue.
php_value memory_limit 32M

4. Or else, Try adding this line to your wp-config.php file:
Increasing memory allocated to PHP
define(’WP_MEMORY_LIMIT’, ’32M’);

If none of the above things solve your issue, then talk to you host. If you have a host like Knownhost who is fast and knows what needs to be done, you do not have to worry much.

Note: I am now worrying on which PHP script required an increase in memory allocation. The analysis won’t be so easy though.

Komentarze

  1. Masz 3 opcje:

    1. Zmiana w .htaccess
    2. Zmiana w wp-config.php
    3. Zmiana hostingu

    1 i 2 opcje znalazłeś sam, i jeśli one nie działają, to zostaje tylko zmiana hostingu – bo to znaczy że blokują zmiany. Jednak jak wpisywałeś 32M – to nie ma się co dziwić, wpisz 128M, albo 256M, tyle aby działało, ale nie za dużo, aby nie przyciągać uwagi.

Dodaj komentarz