title: Fatal error: Allowed memory size of 134217728 bytes exhausted Magento
body: <p>In Magento I got this error. I know this is a memory issue, but I know my code causing this. How can I solve such issue? The same code works for long time and suddenly it generates issue.</p>
  
  <blockquote>
    <p>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 94115841 bytes) in /home/wwwcruk/public_html/cas/app/design/frontend/default/cas/template/brandproduct/brand-listcar.phtml on line 60</p>
  </blockquote>
  
  <p>I allocated <code>256M</code> from htaccess. When I remove code from above file it works.This is the part of code. These are the two lines (<code>$manufacturer['label'][0] == $char</code>) that are causing the issue:</p>
  
  <pre><code> &lt;?php $i=0;$j=0;foreach ($manufacturers as $manufacturer): ?&gt;
  
  &lt;?php if($i == 0 &amp;&amp; $manufacturer['label'][0] == $char): $j++;?&gt;
  
      &lt;li&gt;&lt;span class="levelchar"&gt;&lt;?php echo $char; ?&gt;&lt;/span&gt;&lt;/li&gt;
  
  &lt;?php endif; ?&gt;
  
  &lt;?php if($j&gt;=$heightColumn):?&gt;
  
      &lt;/ul&gt;
  
      &lt;ul class="level-brandul"&gt;
  
  &lt;?php $j=0; endif;?&gt;
  
  &lt;?php while( $manufacturer['label'][0] != $char){ $char++;?&gt;
  
      &lt;?php if( $manufacturer['label'][0] == $char): $j++; ?&gt;
  
      &lt;li&gt;&lt;span class="levelchar"&gt;&lt;?php echo $char; ?&gt;&lt;/span&gt;&lt;/li&gt;
  
      &lt;?php if($j&gt;=$heightColumn):?&gt;
  
      &lt;/ul&gt;
  
      &lt;ul class="level-brandul"&gt;
  
  &lt;?php $j=0; endif;?&gt;
  
  &lt;?php endif; ?&gt;
  
  &lt;?php }?&gt;
  </code></pre>
  
  <p>I still got the error after increasing memory limit.</p>
  
  <pre><code>[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
  </code></pre>