php 致命错误:允许的内存大小为 268435456 字节已用尽(尝试分配 71 字节)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21680244/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:22:30  来源:igfitidea点击:

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

phpwordpressfatal-errormemory-limit

提问by Tarek Ezzat

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

当我尝试在我的 wordpress 脚本中打开我的仪表板页面之一时出现错误

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

致命错误:第 2685 行的 /home/admin/domains/filesick.com/public_html/wp-includes/taxonomy.php 中允许的内存大小为 268435456 字节(试图分配 71 字节)

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.

我四处询问并被告知我必须将 memory_limit 增加到高于 256M 的值,所以我将其更改为 512M 并且仍然存在同样的问题。然后我将其更改为 3024M,这就是我现在拥有的,但这并没有解决问题。

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

所以你能告诉我如何解决这个问题,我该怎么办?

Waiting for your response.

等待你的答复。

回答by Dave Ross

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_LIMITin wp-config.php:

WordPress 将 PHP 的内存限制覆盖为 256M,假设之前设置的任何内容都太低而无法呈现仪表板。您可以通过定义WP_MAX_MEMORY_LIMITin来覆盖它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.

我同意 DanFromGermany 的观点,256M 确实是渲染仪表板页面的大量内存。更改内存限制实际上是在解决问题。

回答by user3707094

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.

我有这个问题。我搜索了互联网,接受了所有建议,更改了配置,但问题仍然存在。最后在服务器管理员的帮助下,发现问题出在MySQL数据库的列定义上。a 表中的一列被分配给“Longtext”,这导致分配 4,294,967,295 位内存。如果您不使用 MySqli prepare 语句,它似乎可以正常工作,但是一旦您使用了 prepare 语句,它就会尝试分配该数量的内存。我将列类型更改为需要 16,777,215 位内存空间的 Mediumtext。问题消失了。希望这有帮助。