shopify Liquid error: Memory limits exceeded

Tourist
16 0 1

I was trying to dispaly all the product types in one page  , 2 days back it was listing all the all the product type.

But now when that page is loads its giving error like "shopify Liquid error: Memory limits exceeded"

Here is my code

<div class="rte">
  {{ page.content }}
  <ul class="vendor-list block-grid three-up mobile one-up">
{% for product_type in shop.types %}
{% assign its_a_match = false %}

{% capture my_collection_handle %} {{ type | handleize | strip | escape  }} {% endcapture %}
{% assign my_collection_handle_stripped = my_collection_handle | strip | escape %}

{% for collection in collections %}
{% if my_collection_handle_stripped == collection.handle %}
{% assign its_a_match = true %}
{% endif %}
{% endfor %}

{% if its_a_match %} 
<li class="vendor-list-item"><a href="/collections/{{ product_type | handleize }}">{{ product_type }}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>

Why this problem is coming . how can i overcome this problem ?

0 Likes
Shopify Expert
1 0 0

I know this is a bit of an old thread now, but thought I'd post in here in case it's useful for others looking for solutions - we recently wrote an article on our blog about this error: http://blog.pixelcabin.io/2017/09/21/liquid-memory-leaks-in-shopify.

Re the above, it looks like the liquid could be optimised by accessing the collection directly by using the collection[collection_handle]` syntax, which would reduce the need for looping through all the collections:

{% assign its_a_match = false %}
{% assign handleized_product_type = product_type | escape | strip | handleize %}
{% assign collection = collections[handleized_product_type] %}
{% if collection.handle != '' %}
  {% assign its_a_match = true %}
{% endif %}
0 Likes
New Member
2 0 0

I am also facing the same problem,please give the solution quickly. It down my customers.

0 Likes