Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)

I'm getting an error when I try to open one of my dashboard pages in my wordpress script

The error message is as follows:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) in /home/admin/domains/filesick.com/public_html/wp-includes/taxonomy.php on line 2685

I asked around and was told I have to increase the memory_limit to something higher than 256M, so I changed it to 512M and still the same problem. Then I changed it to 3024M and this is what I have now, but that didn't fix the problem.

So could you please tell me how to fix this and what should I do?

Waiting for your response.

like image 550
Tarek Ezzat Avatar asked Feb 10 '14 14:02

Tarek Ezzat


People also ask

How do I fix fatal error allowed memory size?

To fix the error, you have to manually increase the default PHP memory limit set for your server.

How do I check my PHP memory limit?

An attacker can view the memory limit set by executing phpinfo() function to see the memory limit and plan an attack according to the value. A server administrator can set memory limit from -1 (No memory allocation) to any size. The memory limit was first introduced as a setting in php.

What is the maximum PHP memory limit?

Increasing the PHP memory limit The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.


2 Answers

WordPress overrides PHP's memory limit to 256M, with the assumption that whatever it was set to before is going to be too low to render the dashboard. You can override this by defining WP_MAX_MEMORY_LIMIT in wp-config.php:

define( 'WP_MAX_MEMORY_LIMIT' , '512M' ); 

I agree with DanFromGermany, 256M is really a lot of memory for rendering a dashboard page. Changing the memory limit is really putting a bandage on the problem.

like image 176
Dave Ross Avatar answered Oct 30 '22 04:10

Dave Ross


I had this problem. I searched the internet, took all advices, changes configurations, but the problem is still there. Finally with the help of the server administrator, he found that the problem lies in MySQL database column definition. one of the columns in the a table was assigned to 'Longtext' which leads to allocate 4,294,967,295 bites of memory. It seems working OK if you don't use MySqli prepare statement, but once you use prepare statement, it tries to allocate that amount of memory. I changed the column type to Mediumtext which needs 16,777,215 bites of memory space. The problem is gone. Hope this help.

like image 42
user3707094 Avatar answered Oct 30 '22 04:10

user3707094