PHP CLI脚本忽略memory_limit,崩溃数量远低于limit [英] Php CLI script ignoring memory_limit, crashing at much lower number than limit

查看:217
本文介绍了PHP CLI脚本忽略memory_limit,崩溃数量远低于limit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我的一个php脚本忽略了php.ini内存限制或ini_set.

for some reason, my one of my php scripts are ignoring the php.ini memory limit or ini_set.

当我执行print_r(ini_get_all)时,当我的脚本死于致命错误时,它显示设置为100M的全局内存限制(以及本地内存限制):内存不足(已分配24714304)(试图分配571个字节)

When i do a print_r(ini_get_all) it shows the global memory limit set to 100M (and local for that matter), when my script dies at Fatal error: Out of memory (allocated 24714304) (tried to allocate 571 bytes)

有关诊断此问题的任何提示?该服务器具有8gig的内存,以前从未运行过此脚本.

Any tips on diagnosing this? The server has 8gigs of memory and never had problems running this script before.

有任何调试技巧吗?

谢谢!

推荐答案

最常见的原因是通常CLI CLI二进制文件使用的php.ini文件与您预期的不同.这可能是由于

The single most common cause of this is that usually the CLI PHP binary is using a different php.ini file than you expect. This can be caused by user permissions, or simply different default php.ini files for installed versions of PHP. However, it sounds like you've profiled it a bit and your memory limit may be correct inside your script.

在这种情况下,很有可能对操作系统施加的进程进行硬性存储限制,在这种情况下,您必须弄清楚拼版的来源.

In that case, it's quite possible that there is a hard memory limit on processes that is imposed by your operating system, in which case you'll have to figure out where the imposition comes from.

我建议您看一下此内容,因为该海报经历的情况与您的情况非常相似.

I suggest taking a look at this thread, as that poster went through something very similar to your situation.

这篇关于PHP CLI脚本忽略memory_limit,崩溃数量远低于limit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆