php提取函数导致在IIS上运行时内存耗尽


php extract function cause memory exhausted when running on IIS

我的代码在PHP 5.2.8 + IIS6 ISAPI虚拟主机上运行时遇到了一个非常奇怪的问题。

页面报告错误"致命错误:允许的内存大小268435456字节耗尽(试图分配536870912字节)",当我使用以下代码。

$comments = $Comment_Model->getComments(2, $logid, 'n', $commentPage);
extract($comments);

但是如果我没有使用"$comments"来提取,没有错误报告。

extract($Comment_Model->getComments(2, $logid, 'n', $commentPage));

what I have try:

  1. 通过在脚本中添加ini_set('memory_limit', ")来增加内存,但不工作。
  2. 将脚本移动到其他服务器,它可以工作。

这看起来像是环境问题,有人知道吗?

我也有同样的问题,ini_set()不能在我的共享主机上提高内存限制。根据您的服务器设置,一些ini选项不允许通过ini_set()更改。您可能需要编辑php.ini文件,有些主机提供商允许,有些则不允许。我还建议您确保脚本确实需要那么多内存(对代码来说不是问题)。