PHP 致命错误:内存不足(已分配 1707606016)(尝试分配 426680697 字节)

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

PHP Fatal error: Out of memory (allocated 1707606016) (tried to allocate 426680697 bytes)

phpmemoryapache2

提问by Cameron Swyft

I have a droplet on DigitalOcean, it was a 10$ package with 1GB Memory, then I upgraded to 20$ package.

我在 DigitalOcean 上有一个 Droplet,它是一个 10 美元的套餐,带有 1GB 内存,然后我升级到了 20 美元的套餐。

So how it all started was that I'm trying to upload a file from one server to another using cURL parameters, now the issue is... The file doesn't send because I get this beautiful error.

所以这一切的开始是我试图使用 cURL 参数将文件从一台服务器上传到另一台服务器,现在的问题是......文件没有发送,因为我收到了这个美丽的错误。

PHP Fatal error:  Out of memory (allocated 1707606016) (tried to allocate 426680697 bytes)

Now I have memory_limitset to 2048MB because that's how much MB of memory I got on my VPS. Now before I upgraded, I had only 1024MB of memory and the error message was different at the time, and this is what I got.

现在我已memory_limit设置为 2048MB,因为这是我在 VPS 上获得的 MB 内存。现在在升级之前,我只有1024MB的内存,并且当时的错误信息不同,这就是我得到的。

PHP Fatal error:  Out of memory (allocated 530055168) (tried to allocate 529639729 bytes) 

My VPS has MORE than enough memory to upload a 403MB file, and I have my memory_limit maxed, there's no way I need to upgrade the servers memory limit.

我的 VPS 有足够的内存来上传 403MB 的文件,而且我的 memory_limit 已达到最大值,我无法升级服务器的内存限制。

memory_limit = 2048M
file_uploads = On
upload_max_filesize = 5000M
max_file_uploads = 20
allow_url_fopen = On
post_max_size = 0
max_execution_time = 90000
max_input_time = 90000

Obviously it may look like a duplicate, but the solutions on all of the posts I've looked at don'twork for me. The script that is having its memory_limit is literally a handler that handles the cURL request sent from the alternative server.

显然它可能看起来像重复,但我看过的所有帖子中的解决方案都不适合我。具有 memory_limit 的脚本实际上是一个处理程序,用于处理从备用服务器发送的 cURL 请求。

回答by Pratik Kamani

You can changed the php.ini

您可以更改 php.ini

memory_limit = -1

and add to httpd.conf And restart Apache

并添加到 httpd.conf 并重新启动 Apache

回答by Tadeo

I had the same issue in a DigitalOcean droplet of 1GB of RAM and 1CPU. Trying to install two differents LMS systems, Claroline and Chamilo. I upgraded the droplet to 2GB of RAM and same CPU.

我在 1GB RAM 和 1CPU 的 DigitalOcean Droplet 中遇到了同样的问题。尝试安装两个不同的 LMS 系统,Claroline 和 Camilo。我将 Droplet 升级到 2GB 的 RAM 和相同的 CPU。

The issue was solved. Deffintively it was something related to memmory limits.

问题解决了。确切地说,它与内存限制有关。

回答by Pankaj Chauhan

You can changed the php.ini

您可以更改 php.ini

memory_limit = 128M

and add to httpd.conf And restart and restart apache

并添加到 httpd.conf 并重新启动并重新启动 apache