【问题标题】:Internal Server Error 500, out of memory error running Yii内部服务器错误 500,运行 Yii 内存不足错误
【发布时间】:2012-04-18 21:50:17
【问题描述】:

所以我正在运行 Yii,它有一个管理一些科学数据的应用程序。

我在 CentOS 上运行 Apache。

PHP 版本 5.2.10 Apache/2.2.3 (CentOS)

这是我的错误日志(混淆的个人识别信息)。

[Wed Apr 18 15:27:42 2012] [error] [client 000.000.000.000] PHP Notice:  Use of undefined constant \x94512M\x93 - assumed '\x94512M\x93' in /var/www/MySite/www/admin/index.php on line 12, referer: http://MySite.com/admin/index.php?r=factsheet/admin
[Wed Apr 18 15:27:44 2012] [error] [client 000.000.000.000] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 57 bytes) in /var/www/MySite/www/yii/framework/db/ar/CActiveRecord.php on line 1856, referer: http://MySite.com/admin/index.php?r=factsheet/admin

如果我将 renderPartial() 从视图中移除,我可以加载页面,因此它似乎与此相关。

CActiveRecord.php:

protected function instantiate($attributes)
{
    $class=get_class($this);
    $model=new $class(null);
    return $model;
}

我的模特:

Extends an abstract class which extends GxActiveRecord. 

查看:

<?php

$this->breadcrumbs = array(
    $model->label(2) => array('index'),
    Yii::t('app', 'Create'),
);
$this->menu = array(
    array('label'=>Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')),
    array('label'=>Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')),
);
?>
<h1><?php echo Yii::t('app', 'Create') . ' ' . GxHtml::encode($model->label()); ?></h1>
<?php
$this->renderPartial('_form', array(
        'model' => $model,
        'buttons' => 'create'));
?>

index.php 的第 12 行

ini_set(“memory_limit”,”512M“);

有什么想法吗?

【问题讨论】:

  • 您在该部分中运行任何痛苦的查询,显然使用了您传入的模型对象?发布查询,可能没有优化。

标签: php yii


【解决方案1】:

消息

[Wed Apr 18 15:27:42 2012] [error] [client 000.000.000.000] PHP Notice:  Use of undefined constant \x94512M\x93 - assumed '\x94512M\x93' in /var/www/MySite/www/admin/index.php on line 12, referer: http://MySite.com/admin/index.php?r=factsheet/admin

表示您错过了变量前的 $ 符号。

请提供 index.php 的第 12 行。我不认为问题出在上面提供的来源中。

消息

[Wed Apr 18 15:27:44 2012] [error] [client 000.000.000.000] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 57 bytes) in /var/www/MySite/www/yii/framework/db/ar/CActiveRecord.php on line 1856, referer: http://MySite.com/admin/index.php?r=factsheet/admin

经常表示某个循环的 PHP 操作或复杂的查询。

您可以增加 PHP 内存的数量,但这很可能无法解决实际问题。

【讨论】:

  • +1:尝试分配 57 字节通常是一个额外的数组条目。
猜你喜欢
  • 1970-01-01
  • 2016-12-22
  • 1970-01-01
  • 2019-01-17
  • 2011-10-17
  • 2010-11-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多