2012-04-18 89 views
2

所以我运行Yii,它有一个管理一些科学数据的应用程序。内部服务器错误500,运行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“); 

任何想法?

+0

您在该部分运行任何痛苦的查询显然使用您传入的模型对象?发布查询,很可能没有优化。 – 2012-04-18 21:55:17

回答

4

消息

[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 

表明,你一个变量之前错过了$ -sign。

请提供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内存量,但这很可能不会解决实际问题。

+0

+1:试图分配57个字节经常是一个额外的数组入口。 – hakre 2012-04-18 22:00:23