Clear Memory of script when running multiple times

  • Goal: I am trying to achieve the following. I have a large SQL query that I need to join with a hardcoded array ( I know) I do this using a JS script. However everything the SQL database is fetched again the memory used by the script is increased by however much the final concatenated array is. I have to return the array to display it in a table.

  • Steps: I have tried invalidateCache() but since it is memory and not cache this does nothing. Is there something that I can use to clear the memory used by the previous runs?

  • Screenshots:

Original memory used by script:
Screenshot 2024-11-07 at 11.17.40

After running a few times:
Screenshot 2024-11-07 at 11.18.01

Any help is greatly appreciated, end users have this app open for the whole day and it is crazy memory intensive!

Hi @Majesteit1,

Thanks for reaching out! Are these screenshots from the Retool debug console (Perf tab)?

Could you share more about your use case - roughly how many users? roughly how large is the SQL query? Are you using query caching/how often is the query refreshed? Are users experiencing increasingly poor app performance?

Not sure if it would be helpful for this app, but you can clear any data from the front-end client-side by calling queryName.reset()

Hi Tess, thank you for you reply.
Yes these screenshots are from the performance tab in the Debug Modal!

I am not sure if the users really matter but lets say 10?

The two queries, one is sql, that joinActionsAndOffboards join are about 1.9mb (SQL) and a smaller query. Users have experienced decreasing app performance

I will try .reset() and update this ticket if it works!

1 Like

Thanks! :crossed_fingers: hope it helps