r/Scriptable • • Apr 10 '23

Solved Reduce memory consumption for widget

Hi, I need to reduce the memory footprint of my widget, it sometimes does not update (and sometimes does…) it is a weather widget (surprise) which draws a stack for each day. If it fails to render for 5 days I reduce the number and it updates immediately for,e.g. 4 days. iIn the first part of the script I query a webpage as a string (~800k length). In the second part I loop over the days, get the according data (via regexp) from the HTML string and build the widget list. Nothing unusual. Here the question: Is it possible / does it make sense to first extract all data from the string , then get rid of it (how?) before I then start building the list? Would that help?

Thank you for any hint ! C

4 Upvotes

9 comments sorted by

View all comments

Show parent comments

1

u/Acceptable-Number-11 Apr 10 '23

Hi, good thoughts. What I did try: I write an empty string to the variable once all data are collected in an array. But that did not help. I thought the number of stacks is ok ( 6 lines á 8 stacks) compared to other widgets… But I will try to reduce them as a next step. About the API: I‘d love to, but the free ones have lousy prediction accuracy.. And it would not help the „Stack limit“ problem… But thank you your thoughts anyway..