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

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

问题描述

您是否知道从 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.

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

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 中)case) 和其他错误一样吗?

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天全站免登陆