【发布时间】:2014-04-18 17:50:23
【问题描述】:
在 Magento 中我得到了这个错误。我知道这是一个内存问题,但我知道我的代码导致了这个问题。我该如何解决这样的问题?相同的代码运行了很长时间,突然就产生了问题。
致命错误:/home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml 中允许的内存大小为 134217728 字节已用尽(尝试分配 94115841 字节)第 60 行
我从 htaccess 分配了256M。当我从上面的文件中删除代码时,它可以工作。这是代码的一部分。这是导致问题的两行 ($manufacturer['label'][0] == $char):
<?php $i=0;$j=0;foreach ($manufacturers as $manufacturer): ?>
<?php if($i == 0 && $manufacturer['label'][0] == $char): $j++;?>
<li><span class="levelchar"><?php echo $char; ?></span></li>
<?php endif; ?>
<?php if($j>=$heightColumn):?>
</ul>
<ul class="level-brandul">
<?php $j=0; endif;?>
<?php while( $manufacturer['label'][0] != $char){ $char++;?>
<?php if( $manufacturer['label'][0] == $char): $j++; ?>
<li><span class="levelchar"><?php echo $char; ?></span></li>
<?php if($j>=$heightColumn):?>
</ul>
<ul class="level-brandul">
<?php $j=0; endif;?>
<?php endif; ?>
<?php }?>
增加内存限制后我仍然收到错误。
[Mon Apr 21 10:52:52 2014] [error] [client 82.94.176.140] in /home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml on line 47, referer: http://creationsautosport.co.uk/cas/index.php/catalog/product/view/id/58/s/bmw-m-power-silver-number-plate-surrounds/category/4/
[Mon Apr 21 10:49:50 2014] [error] [client 82.94.176.140] Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 504104961 bytes) in /home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml on line 47, referer: http://creationsautosport.co.uk/cas/index.php/catalog/product/view/id/58/s/bmw-m-power-silver-number-plate-surrounds/category/7/
[Mon Apr 21 10:47:08 2014] [error] [client 82.94.176.140] Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 504104961 bytes) in /home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml on line 47, referer: http://creationsautosport.co.uk/cas/index.php/catalog/product/view/id/58/s/bmw-m-power-silver-number-plate-surrounds/category/9/
[Mon Apr 21 10:46:56 2014] [error] [client 39.47.121.31] Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 496762881 bytes) in /home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml on line 47
【问题讨论】:
-
@Stony 当我将此代码放入 index.php 文件
ini_set('memory_limit', '-1');时,我得到了500 Internal Server Error。 -
典型的内存不足分配错误 (128M),Magento 需要 256M 或更多。更高版本,10k 目录,10k 客户,使其达到 512M 或更多。如果您正在运行外部 php 脚本,您还需要确保命令行 php 解释器也设置了内存限制。
-
@FiascoLabs 我已将内存增加到
512MB,但仍然错误。您可以在我的问题中看到上述内容。
标签: php .htaccess magento memory-management