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

3

55

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.

Puny answered 10/2, 2014 at 14:46 Comment(9)
It sounds like your memory limit change is not being applied. You might be editing the wrong file. Try to run php_info() in a script in the same directory as your wordpress installation, and check the output for the actual memory_limit there.Bostic
At a guess, you've got some code that's causing an infinite loopShaving
Instead of increasing memory, I'd fix the dashboard and remove everything unnecessary..Inconspicuous
well it's not my code it's the coder that i paid him to do the whole site and he said that it's not his code it;'s the server that i should checkPuny
tell him to fix it and make the scripts use less resources or don't pay him honestly wtf 250MB of data for a dashboard do you know how much data this is...Inconspicuous
@Bostic could you please give me instructions on how to do that and i am opening the php.ini file i'm sure and i save using the ctrl+oPuny
actually, as andrewsi suggested there may be a problem in the program, does the allowed memory size of xxxx error change when you change the limit? that would indicate that all the memory is being consumed, no matter how much you increase it byBostic
no @Bostic it doesn't it's always 268435456 bytes does that say something ?Puny
That means the memory limit isn't being changed by your edits. This can have various causes, but there is a setting in wp-config.php define("WP_MEMORY_LIMIT", 512);Bostic
T
72

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.

Tallbot answered 10/2, 2014 at 15:21 Comment(5)
thank you so much Dave it works but please what does that mean where is the issue like what is the reason that lead to this problem the coder or the server ?Puny
It depends on what the code is doing, there could be a legitimate reason for having to use so much memory, e.g. processing large files, but even for large files, instead of reading the whole thing into memory there can be a way to process it in chunks.Bostic
Sometimes it's the platform itself. For example in the WordPress (3.8.3) code /wp-includes/wp-db.php starting on line 1240 there is a loop that is supposed to accumulate the results of a database query into an array. This failed for me at around 26,800 posts. Now I cannot tell why the WordPress team chose to load all the posts in one call, but the admin dashboard fails as a result of this.Melano
@dave What is the difference? 'WP_MEMORY_LIMIT'Weave
@Weave WordPress assumes the admin section will use more memory, so WP_MEMORY_LIMIT controls the maximum memory available normally, while WP_MAX_MEMORY_LIMIT sets the maximum just on admin pages. It's a terrible naming scheme but it dates back to WordPress 2.5 and nobody dares change it now. See codex.wordpress.org/…Tallbot
T
24

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.

Tern answered 28/1, 2016 at 10:58 Comment(1)
This is what was causing my PHP app (laravel) to allocate more than 256M - the jobs table (automatically created by Laravel for queueing) contains a LONGTEXT! I changed it MEDIUMTEXT (16MB, more than sufficient)Asbestosis
C
8

I changed the memory limit from .htaccess and this problem got resolved.

I was trying to scan my website from one of the antivirus plugin and there I was getting this problem. I increased memory by pasting this in my .htaccess file in Wordpress folder:

php_value memory_limit 512M

After scan was over, I removed this line to make the size as it was before.

Comeon answered 24/6, 2020 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.