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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3674197/
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 10:39:12  来源:igfitidea点击:

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

phpmemory

提问by Rekha

Possible Duplicate:
Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

可能的重复:
在 php 中允许的内存大小为 33554432 字节(试图分配 43148176 字节)

Hi,

你好,

In my php page, I got the error as follows,

在我的 php 页面中,我收到如下错误,

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

I tried to set memory limit using ini_set('memory_limit', '128M');

我尝试使用设置内存限制 ini_set('memory_limit', '128M');

But still I got the error.

但我仍然收到错误。

Any help would be really appreciated.

任何帮助将非常感激。

回答by Jon Skeet

128 megabytes is134,217,728 bytes. You've used up that memory. You either need to set the limit higher(if you can; I don't know if PHP will allow that) or simply use less memory in your code.

128 兆字节134,217,728 字节。你已经用完了那块内存。您要么需要将限制设置得更高(如果可以的话;我不知道 PHP 是否允许这样做),或者只是在代码中使用更少的内存。

Do you expect your page to be using a lot of memory? If so, maybe raising the limit (or setting it to -1, which is somewhat dangerous in terms of allowing unlimited memory use) is the right thing to do. If not, look through your code for places where you could be effectively leaking memory. You might want to try replacing sections of your page with "dummy" blocks, one at a time, until you find the offending section.

您希望您的页面使用大量内存吗?如果是这样,也许提高限制(或将其设置为 -1,这在允许无限内存使用方面有些危险)是正确的做法。如果没有,请查看您的代码以查找可能有效泄漏内存的地方。您可能想尝试用“虚拟”块替换页面的某些部分,一次一个,直到找到有问题的部分。