liquid error: memory limits exceeded

Shopify Partner
122 0 25

Does anyone know what exactly causes this?  I'm quite sure I know what's causing it on my site, I have a non app wishlist set up which uses customer tags to flag products.  See here: https://github.com/zakhardage/Shopify-Wish-List

When the customer creates too many tags, like over 200 at this point, I get the error.

Can anyone shed some light on this?

Thanks

0 Likes
Highlighted
Shopify Expert
9887 101 1730

Where's the confusion? You seem to know it's related to too many customer tags. The error makes sense really. The code could easily create a situation where the code needs to do 40,000 loops or more. No doubt there's a hard limit internally on this.

[edit] Looking at the code it could be improved a bit. Doubt that would help, but some optimisation can't hurt.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
122 0 25

thanks for your answers, how do you think the code could be optimized?

1 Like
Highlighted
New Member
2 0 0

Please give us a proper answer to solve this problem.Be quick in solution because it show fault in our store.

0 Likes
Highlighted
Tourist
9 0 1

@shoelay @Peter1 - I had same issue on client's store, when I looked onto main theme js file I found nested loop which looks like this:

{% for collection in collections %}
    {% for product in collection.products %}
       {% for variant in product.variants %}
           all_variants[{{ variant.id }}] = {
            inventory_policy: "{{ variant.inventory_policy }}",
             inventory_management: "{{ variant.inventory_management }}",
            inventory_quantity: {{ variant.inventory_quantity }}
         };
      {% endfor %}
    {% endfor %}
{% endfor %}

By removing outer two loop it works PERFECT for me, and "Memory Limits Exceeded"  issue has been resolved  as well and theme is working perfectly Awesome. This is what I replaced:

       {% for variant in product.variants %}
           all_variants[{{ variant.id }}] = {
            inventory_policy: "{{ variant.inventory_policy }}",
             inventory_management: "{{ variant.inventory_management }}",
            inventory_quantity: {{ variant.inventory_quantity }}
         };

 Hope it help :)

Regards,
Khalid 

0 Likes
Highlighted
Tourist
12 0 1

Hi I am using a turbo theme and after configuring my sidebar I started having this error code. how do I go about it because I cannot find theme.js in turbo theme?

1 Like
Highlighted
Tourist
9 0 1

Hey @Mbglo in the assets folder their should be a main js file either app.js or something like this, can you share the screenshot of your asset folder, and if this error occurs after you configure your side bar, then it means that particular liquid file which have the code of your side bar is having issue. developer.rutherford@gmail.com 

send me the details here i can look at your issue.

 

Thanks.

0 Likes
Highlighted
Tourist
12 0 1
Hi I found app.js in the assets folder. I don’t know how to send screenshot here. What should I do in the app.js
0 Likes
Highlighted
Shopify Partner
15 0 0

hi khalid, ive just run into a similair problem on my larger collections that have lots of various tags on the turbo theme sidebar. Ive attached a screenshot on the file as requested and hope you can help as im still waiting for a reply from OOTS.

 

Screenshot 2020-05-05 at 22.22.45.png

0 Likes
Highlighted
Tourist
9 0 1
Hey can you create my staff account so i can look into this?
0 Likes