Overusing Storage.setValue()?

Some of you might have got ERA reports with crashes when using Storage.setValue(). I have had them a lot. Although I think the original problem is on Garmins end I'm thinking I might be overusing Storage.setValue().

I have a timer that updates every second. And at the end of the loop, I store the value in storage to be able to access it from the menu etc. Since everything has worked before, i didn't think much about it, but is this a bit of overuse of the setValue()? I thought it should handle write every second, but I could of course reduce the number of writes by writing whenever I go to the menu or any other page apart from my main page.

This would not remove all calls to setValue() but would certainly reduce my exposure to the risk. Am I not using setValue as intended?

  • Thank you for your quick and complete answer! You've always been helpful, really appreciated.

  • The code I grabbed is actually from a widget with a background service that runs every few minutes and also publishes complications, and passing this with globals, impact the memory used for the background service.

    In onBackgroundData, I do save the data to Storage, but that's only once every few minutes (15 minutes by default) so it's available if you close the widget and then open it again.