Homey script App cashes often, error "Exit Code: null, Exit Signal: SIGKILL"

I have dozens of scripts in Advanced flows. On an irregular basis, the Homey script app crashes with the error message “Exit Code: null, Exit Signal: SIGKILL”.

According to AI: “This happens in 99% of cases because the script consumes too much working memory (RAM) or keeps the processor (CPU) occupied for too long without interruption”.
How can I identify the cause of this error and in which script it occurs?

A script can start multiple instances, like, when it started while it wasn’t finished yet, it starts another instance.
Running too many instances causes excessive RAM usage.

You can check Insights Homeyscript Memory usage, for when it happens, this might point you to the suspect scripts.

(This is just to point to the graph, it’s not an example of destructive RAM peaks)

At 9:30 the Homey script app went down with a 40% CPU usage

The spike in CPU usage is due to the app starting back up again, it looks like it got killed because of a memory leak that caused the amount of RAM being used to slowly increase.

How could I identify which scripts are causing this memory leak? Some scripts are executed sequentially.

The number of combinations is too large to test each script individually. It is more likely the combination of scripts to be executed.

Or is a memory leak something that Athom needs to investigate?

Simply said: you can’t :man_shrugging:t3:

You have to do some guessing which scripts could be candidates for memory leaks. For instance, scripts that use timers (setTimeout/setInterval), callback functions (like event handlers, etc) or scripts that use globals a lot. And/or scripts that have been generated by “AI”, since LLM’s don’t understand the intricacies of running HomeyScript.

Doubtful, at least I don’t see why a combination of scripts could cause a leak where an individual script can’t.

It’s more than likely not an issue with the HomeyScript app itself.

I don’t think it’s a memory leak.
Like I already wrote, every running (instance of a) script increases Homeyscript’s RAM use, until it gets past a threshold at some point, and Homey kills it.

150MB RAM usage really is huge, here it’s around 116MB in general.

I’d first check scripts which wait for a value or input; these can have many running instances > which should be avoided as much as possible.

And I’d check on scripts which get executed very often (less than each minute or so).

I generate ~20 full screen SVGs and Markdown tables (not at the same time) using multiple Homey scripts by selecting dashboard menu options. The results are sent to that dashboard via a subsequent card using a script Return variable.

It seems that the memory of these variables is not being cleared, or is being cleared poorly, even after Advanced Flow has finished. I reboot the Homey device every night.

Any tips?

This sort of usage is probably something that Athom never considered, so it wouldn’t surprise me if indeed there’s data left dangling. However, it’s nearly impossible to debug where, and if it’s even possible to fix it. So other than rebooting Homey nightly, or the HomeyScript app, you will keep running into this issue.

Yes, but the Homey script app restarts multiple times a day with this error message, causing the Homey scripts to stop responding.

You can restart it from a flow:

(possibly only when the Power User experiment is turned on)

Otherwise I don’t see any other solution.