如何从致命错误中恢复“允许的内存大小耗尽” [英] How to recover from a fatal error "Allowed memory size exhausted"

查看:115
本文介绍了如何从致命错误中恢复“允许的内存大小耗尽”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否知道从PHP致命错误中恢复的任何解决方案:允许内存大小...耗尽

Do you know any solution to recover from the PHP fatal error : "Allowed memory size ... exhausted"

我有一个关闭功能,当出现致命错误时调用。这个函数从它创建一个ErrorException,并记录它。

I have a shutdown function that is called when a fatal error appear. This function create an ErrorException from it, and logs it.

问题是:当没有更多的内存可用时,它无法记录错误(我登录FireBug,通过FirePHP,与Zend Framework)。

The problem is : when there is no more memory available, it can't log the error (I log in Firebug, via FirePHP, with Zend Framework).

所以我的意思是如何从它恢复,是如何执行基本错误日志,让Zend Framework发送头文件,以便在任何其他错误记录错误(在我的情况下在Firebug中)?

So what i mean by "how to recover from it", is how to perform basic error log, and let Zend Framework send the Headers, so that the error is logged (in Firebug in my case) as any other error ?

谢谢

推荐答案

这个错误是一个致命的错误 - 这意味着你无法从中恢复。如果PHP已经达到内存限制,它将无法分配任何更多的内存来创建它的异常和任何其他需要执行的内存。

This error is a fatal error - that means you cannot recover from it. If PHP has hit it's memory limit, it won't be able to allocate any more memory to create your exception and any other memory it needs to carry on its execution.

还有另一种类型的错误 - 可捕获的致命错误,顾名思义,可以抓住一个try / catch,但不幸的是内存大小分配不是其中之一。

There is another type of error - "catchable fatal error" which as the name suggests, can be caught in a try/catch, but unfortunately the memory size allocation is not one of them.

这篇关于如何从致命错误中恢复“允许的内存大小耗尽”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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