nebulous / infinitude

Open control of Carrier/Bryant thermostats
MIT License
225 stars 50 forks source link

Long-term memory leak crashes host #127

Closed brettonw closed 1 year ago

brettonw commented 2 years ago

I am running an infinitude server in a container in an integration with home assistant. The server is configured as the proxy in a Carrier Infinity Thermostat. I have a home assistant automation that is setting the target temperature on the infinitude server once per minute (there are a variety of other system and network reliability issues at play that I could not work around without this brute force effort to make sure the infinitude system was synch'ed with the HASS thermostat action goals). The infinitude server slowly grows its memory process space until it runs out of memory, and the host computer crashes. A second infinitude server that never gets set this way does not exhibit this behavior.

nebulous commented 2 years ago

Hi, @brettonw - thanks for your report. While I acknowledge that a memory leak like this isn't ideal, it's a bit of an edge case and this looks like an XY problem. But, if we take as given that the issues which lead to the brute force HA sync are insurmountable, then a fairly simple/reliable (if equally brutish) solution would be to periodically restart the infinitude container. Depending on how you run the container this could even be done automatically by setting a memory limit. How quickly does the container bloat?

brettonw commented 2 years ago

Your solution is what I adopted, and I am looking at ways to reduce the need to constantly update the temperature.

It is an XY problem in the sense it's a brute force solution to a complex system with a lot of unreliable elements that cannot be made unreliable. I could go into details, but... the short explanation is I use my thermostat like an on/off switch from a separate temperature sensor. The undesirable artifact of this memory leak is the infinitude container stops responding to temperature change requests, and the HVAC system never stops or starts.

I was previously running an infinitude container on a 2GB RPi 4 without swap, and setting the temperature once per minute would crash the host in about 30 hours. That host is also running Home Assistant, so my whole house would go down with it. I've switched to a 4Gb Rpi4 (ubuntu 64-bit OS) with 4Gb swap, and the memory space grows at a rate consistent with that observation. The container now has a 512Mb memory limit and is restarted every morning at 6am, I haven't had this problem again.

Screen Shot 2022-01-11 at 9 47 37 AM
brettonw commented 2 years ago

Just a followup, the container capped at 512Mb reboots on about a 17 hour cycle.

brettonw commented 2 months ago

A new followup - newer raspberry pi 5 installations with the docker container do not support memory capping without herculean measures. In this heat - the hvac is getting updated a lot, and this bug is a prominent feature. I've had to resort to simply restarting the containers every day at 4am.