iOS
iOS copied to clipboard
Memory leak
Device model, version and app version
Model Name: Macbook Pro with M1 Max, macOS Version: MacOS 12.3 App Version: Home Assistant Companion 2022.3 (2022.358) Safari Version: Version 15.4 (17613.1.17.1.6)
Home Assistant Core Version
2022.3.5
Describe the bug
Looks like there's a memory leak.
I've been running the companion app in the background for a few days and the system eventually ran out of memory:

To Reproduce
Expected behavior
Screenshots
See above.
Additional context
+1
+1 Been happening for me since January
+1 I have this issue ever since I got the M1 MacBook Pro. The amount of memory allocated by Home Assistant app is insane, Mac's temperature is rising and then there is the battery drain issue.
uninstalled and reinstalled the app with no luck.
I also have the M1Pro Mac Book Pro so it could be an issue with Rosetta 2?
The app does not use Rosetta.
Very likely this is an Apple bug in Catalyst apps, but it can be helpful to narrow down what's taking up memory space. You can help debug this by doing a few things when this occurs:
- In Activity Monitor, double-click Home Assistant and run "Sample" on it.
- On the command line, run
leaks <pid>
(whereis the "process group" number in Activity Monitor) - On the command line, run
heap <pid>
(same as previous)
Save these files off and attach the text files here.
Hey @zacwest
Here are my findings as soon as the app was acting out again
Home Assistant Heaps.txt Home Assistant Leaks.txt Sample of Home Assistant.txt


Thanks @manosioa. Of course the moment I need it to start leaking it doesn't for days
Happening here as well. Reaches up as much as 55gb. Restarted the app and it immediately went up to 8gb memory usage.
Sample of Home Assistant.txt Home Assistant Heaps.txt Home Assistant Leaks.txt
Finally.. Here are mine HAHeaps.txt HALeaks.txt Sample of Home Assistant.txt
After ~4 hours. Also am on M1 (Max).
Thanks for all the logs. I have an idea what may be the cause. Do you all have a lot of entities? I think it may be the app keeping track of states - storing a small part of a state change is keeping the entire API response in memory, which means it'll scale fast if you have many frequent state changes.
I do have a lot of entities. I have a script that essentially starts a “Disco Mode” which very quickly updates all my lights (~50) to random colors. It would always crash the iOS app. So I’ll test this with the macOS app when I get home today.
I too have a lot of entities. The weird thing is that it can run smoothly for an extended period of time and suddenly starts acting up.
Yes, I have a lot of entities.
On Fri, Apr 29, 2022 at 3:56 PM Zac West @.***> wrote:
Thanks for all the logs. I have an idea what may be the cause. Do you all have a lot of entities? I think it may be the app keeping track of states - storing a small part of a state change is keeping the entire API response in memory, which means it'll scale fast if you have many frequent state changes.
— Reply to this email directly, view it on GitHub https://github.com/home-assistant/iOS/issues/2101#issuecomment-1113671209, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABB6R6CQ2GFEOQ4MJPSD4KDVHQ5GVANCNFSM5RABXPZQ . You are receiving this because you commented.Message ID: @.***>
Same.. lots of entities (about 500) and not only is there an issue with memory I have high cpu usage as well. On both the macOS app and systemstats service.
Not sure why it needs to pull all the entities especially when the app is running in the background. I just need it to send some sensor info to home assistant (if my laptop is running, display connected as well etc).
Hi!
Any news regarding this? Still having big issues with the App
MacBook 13" M1 - macOS 13 dev beta 3 It's started to leak more often compared to macOS 12.
Can confirm this issue still happens, might be related to putting macOS to sleep mode often, instead of properly shutting down the computer?
I guess you don't own either a Mac or a modern laptop. You don't have to shutdown the computer. Just closing the lid or in case of an iMac just walking away does the trick. The app should work correctly.
I guess you don't own either a Mac or a modern laptop. You don't have to shutdown the computer. Just closing the lid or in case of an iMac just walking away does the trick. The app should work correctly.
@manosioa I do own a M1 Pro MacBook Pro, I am affected by this issue (I said so, "Can confirm this issue still happens"...)
I am just the kind of person closing my Mac's lid all the time, my current uptime is near one month.
Since solely using sleep mode is something that I reckon not everyone does, I am not saying using sleep mode is wrong, I tried assisting this issue's resolution by hinting "maybe this is related to sleep mode?" which is something that is commonly overlooked in desktop applications.
Of course the app should work correctly, but not every app does, and maybe it is the issue of this specific memory leak.
+1
Piling on to say this happened to me; within a few days of installing the app (2022.387) my 14" MacBook Pro (M1 Pro, 16GB) ground to a halt and completely died after throwing up the "out of memory" screen. Home Assistant was using just shy of 60GB. As far as my usage pattern, my MacBook stays plugged in at my desk pretty much all the time and goes to sleep when idle.
I saw a theory above that this may be exacerbated by having lots of entities....and I have a lot of entities (don't know how many exactly, but many many hundreds, probably around 1000).

Can't you just kill the HA process without having to reboot? Also I think you are the top winner for the most ram usage screenshot. Let's see if anyone can beat it!
@skynet01 I don't think Activity Monitor catches everything it should and the system feels really sluggish until a reboot. It's super odd, I'm not going to use it on my daily driver until this is fixed, it's kind of dangerous.
Got the same, seems to happen when it loses connection to HA.
Hi al, I have the same issue
Apple M1 Pro - MacOS 13.0 (22A380)
Interesting my Force Quit menu doesn't show any memory sizes. Sounds like this problem is only happening on M1 / M2 Macs? My Activity Monitory shows HA is only using 43 MB. (my Mac has an Intel i7)

Maybe this needs some attention now that Reddit has taken notice. Does this need more diagnosis?