2013-05-01 66 views
0

我对Magento非常陌生,刚刚学习模型。我正在尝试遵循Alan Storms教程,并创建了我的模型。但是,下面的代码会导致内存溢出错误:Magento Model-调用加载内存溢出

Allowed memory size of 67108864 bytes exhausted (tried to allocate 65488 bytes) in C:\xampp\htdocs\magento\app\code\core\Mage\Core\Model\App.php on line 447

IndexController.php看起来是这样的:

<?php 
    class Lock_Weblog_IndexController extends Mage_Core_Controller_Front_Action { 
    public function testModelAction() { 
     $params = $this->getRequest()->getParams(); 
     $blogpost = Mage::getModel('weblog/blogpost'); 
     echo("Loading the blogpost with an ID of ".$params['id']); 
     $blogpost->load(1);  
     //$data = $blogpost->getData(); 
     //var_dump($data); 
    } 
    } 
?> 

我的config.xml文件看起来是这样的:

<config>  
    <global> 
    <modules> 
     <Lock_Weblog> 
     <version>1.0</version> 
     </Lock_Weblog> 
    </modules> 
    <models> 
     <weblog> 
     <class>Lock_Weblog_Model</class> 
     <resourceModel>weblog_mysql4</resourceModel> 
     </weblog> 
     <weblog_mysql4> 
     <class>Lock_Weblog_Model_Mysql4</class> 
     <entities> 
      <blogpost> 
      <table>blog_posts</table> 
      </blogpost> 
     </entities> 
     </weblog_mysql4> 
    </models> 
    <resources> 
     <weblog_write> 
     <connection> 
      <use>core_write</use> 
     </connection> 
     </weblog_write> 
     <weblog_read> 
     <connection> 
      <use>core_read</use> 
     </connection> 
     </weblog_read> 
    </resources> 
    </global> 
    <frontend> 
     <routers> 
      <weblog> 
       <use>standard</use> 
       <args> 
        <module>Lock_Weblog</module> 
        <frontName>weblog</frontName> 
       </args> 
      </weblog> 
     </routers> 
    </frontend> 
</config> 

我彻底失去了做什么来解决这个问题! 任何帮助赞赏

+0

什么是您的服务器配置。 – oscprofessionals 2013-05-02 03:52:40

+0

您对我的服务器配置有哪些感兴趣? – Lock 2013-05-02 07:19:33

回答

1

Magento需要256M512M是最好的)memory_limit正常运行的网站。

您只有64M。增加你的php.ini的限制,一切都应该正常工作。

+0

嗨。我应该提到 - 即使将内存增加到512(显然需要更长的时间才会溢出),我也遇到同样的问题。我只是将其更改为更低的数量进行测试。 – Lock 2013-05-01 20:26:19

+0

@Lock发布你的整个代码..可能是你Mage ::记录模型文件中的一些对象,它可以占用整个内存空间? – Kalpesh 2013-05-02 08:23:05