# Homeyscript strange behaviour

**URL:** <https://community.homey.app/t/homeyscript-strange-behaviour/105738>\
**Category:** Questions & Help\
**Tags:** homey-pro\
**Created:** [March 7, 2024, 11:48am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738 "2024-03-07T11:48:38Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 11:48am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/1 "2024-03-07T11:48:38Z")

</div>

I noticed the following serious problem with Homey.

Homeyscript is consuming memory which increases in time.  
After a short period (20 to 90 minuts) there is probably a cleanup function to reset the memory consumption.  
During the memory cleanup (the dips in the graph) **every Homeyscript freezes and does not run during 2 minuts**  
In the graph below I am sure there is no Homeyscript running. (based on triggers that could be fired.)

 ![HomeyScript 1](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/8/e8734e2cdbb8384d2af138f42c3cf217c03ac03b.jpeg)

During the cleanup all Homeyscript flowcards are unavailable

 ![HomeyScript 2](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/e/be24576830802da4a723db7001ab85617f7efb6b.jpeg)

The list of Homeyscripts in the browser are gone (empty).

 ![HomeyScript 3](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/f/0f334bac36c32a547595c632a1938e18c98bb138.jpeg)

May be the cleanup can also cause other Homey internal issues.  
Since I own Homey (April 2023) I noticed many reliability problems .  
For instance :

1. lights not switching on.
2. smart plugs not switching on.
3. no reaction to motion triggers.
4. smart plugs becoming unavailable.
5. lights becoming unavailable.
6. doorbell not ringing.
7. inaccurate person presence.

The Homeyscript issue has been reported to Homey support a time ago.  
Reaction zero until today.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 7, 2024, 11:53am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/2 "2024-03-07T11:53:28Z")

</div>

> [@bergw](#):
>
> After a short period (20 to 90 minuts) there is probably a cleanup function to reset the memory consumption.

No, the app is using too much memory (more than 120MB for more than 50 seconds) and gets restarted. Which also explains why the cards are temporarily unavailable.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 12:22pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/3 "2024-03-07T12:22:45Z")

</div>

The behaviour is not identical when the app restarts manually  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/f/bfc57955ac6d8e7f4cb2d3f9d6f17e26962423e3.png)  
The dip in the graph is after the app restart is intiated. This does not take 2 minuts and does not go to zero.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 7, 2024, 1:21pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/4 "2024-03-07T13:21:49Z")

</div>

An app that gets restarted due to using too much memory basically crashes, which is different from a manual restart. Also, restarts due to crashes are delayed from anywhere between 10 to 120 seconds.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 2:43pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/5 "2024-03-07T14:43:57Z")

</div>

Yes I understand. But found no documentation about this.  
So Homeyscript crashes because it has memory leaks ?  
When not running any script. I see same behavior.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 7, 2024, 3:26pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/7 "2024-03-07T15:26:17Z")

</div>

> [@bergw](#):
>
> But found no documentation about this.

It’s not documented, I’m looking at Homey’s core code.

> [@](#):
>
> So Homeyscript crashes because it has memory leaks ?  
> When not running any script. I see same behavior.

Right after the app is started it’s already consuming about 60MB of RAM. On my Homey, which does absolutely nothing, it’s about the same. However, I don’t see any notable increases in memory, so it’s not leaking memory when it has nothing to do.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 4:40pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/8 "2024-03-07T16:40:31Z")

</div>

Besides reporting again, any suggestion how to solve this ?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 7, 2024, 5:17pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/9 "2024-03-07T17:17:57Z")

</div>

Look closer at your scripts to see if they’re causing the memory leaks.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 5:39pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/10 "2024-03-07T17:39:05Z")

</div>

I already did this more than once (maybe 15 times) and also runned it in the Homey simulator without Homeyscript. No issues reported.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 7, 2024, 5:43pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/11 "2024-03-07T17:43:21Z")

</div>

> [@bergw](#):
>
> and also runned it in the Homey simulator without Homeyscript

No idea what that means.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 7, 2024, 6:41pm UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/12 "2024-03-07T18:41:27Z")

</div>

As it says a simulator that reacts on Homeyscript SDK calls but without the physical Homey.  
It runs a JS module and enables me to debug code as standalone VS Code debug target. It only supports static calls. Or in other words no live support of device responses. I use this for basic code structuring of Homeyscript development. For App development I use a setup which also enables live target debugging for Typescript with VS Code. Maybe somewhere in future there will be a Athom supported development environment for Homeyscript.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 8, 2024, 6:35am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/13 "2024-03-08T06:35:52Z")

</div>

If you’re sure your scripts aren’t leaking, [post an issue](https://github.com/athombv/com.athom.homeyscript/issues) (first look at [#53](https://github.com/athombv/com.athom.homeyscript/issues/53), which might be related).

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 8, 2024, 8:19am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/14 "2024-03-08T08:19:21Z")

</div>

Robert thanks. Issue #53 is indeed related.  
I discovered this issue a few months ago and reported this. Until today zero respons. Not even a confirmation of the receipt.  
Further you said you have read this in the source code. Can you share ? I only have the SDK sources.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [March 8, 2024, 9:02am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/15 "2024-03-08T09:02:23Z")

</div>

> [@bergw](#):
>
> Can you share ?

Legally I probably can’t, but if you have a HP2023 you can [jailbreak your Homey](https://community.homey.app/t/modding-howto-guide-to-jailbreak-a-homey-pro-2023/81678) and access the code yourself.

---

<div class="post-metadata">

**Author:** ![bergw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bergw/32/58663_2.png) [@bergw](https://community.homey.app/u/bergw)\
**Post date:** [March 8, 2024, 9:48am UTC](https://community.homey.app/t/homeyscript-strange-behaviour/105738/16 "2024-03-08T09:48:46Z")

</div>

Thanks,
