Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak? #44

Open
kt767 opened this issue Jul 22, 2022 · 6 comments
Open

Memory leak? #44

kt767 opened this issue Jul 22, 2022 · 6 comments

Comments

@kt767
Copy link

kt767 commented Jul 22, 2022

I have Homebridge 1.5.0 (Node.js v16.16.0) installed on Raspberry Pi 4 (2GB RAM) that is running OpenMediaVault 6. I installed the Tesla Powerwall plugin as a separate bridge this morning, and I can see "home bridge: homebridge-tesla-powerwall" gradually using more and more memory when I run htop (VIRT column goes up consistently). Is anyone else having the same issue? Here's a graph from OMV's GUI:
image

I tried v3.1.0-Beta5, but VIRT memory consistently increases, just like v3.0.0.

Here is my config:

        {
            "platform": "TeslaPowerwall",
            "name": "Tesla Powerwall",
            "_bridge": {
                "username": "1E:82:FA:2C:5F:1F",
                "port": 56251
            },
            "ip": "192.168.82.23",
            "password": "[redacted]",
            "additionalServices": {
                "powerwall": {
                    "eveHistory": false
                },
                "solar": {
                    "homekitVisual": false,
                    "evePowerMeter": false,
                    "eveHistory": false
                },
                "grid": {
                    "positiveEvePowerMeter": false,
                    "negativeEvePowerMeter": false,
                    "eveHistory": false
                },
                "battery": {
                    "positiveEvePowerMeter": false,
                    "negativeEvePowerMeter": false,
                    "eveHistory": false
                },
                "home": {
                    "evePowerMeter": false,
                    "eveHistory": false
                }
            }
        },
@datMaffin
Copy link
Owner

Any long term experience? Did the usage level off at some point?

@kt767
Copy link
Author

kt767 commented Sep 10, 2022

I didn't notice the usage leveling off after a few days, so I ended up uninstalling it.

@longzheng
Copy link

I've also experienced this since installing this plugin. I haven't had much time to debug it further but restarting it recovered about 3GB for me after 3 days of usage.

@datMaffin
Copy link
Owner

datMaffin commented Sep 26, 2022

As long as only the virtual memory increases, it should not be a problem. (Linux can basically provide an infinite amount of virtual memory).

I do not like that it seems to be triggered by this plugin, though: Are other Homebridge plugins fine?
I will check if I can see similar behavior, but the memory usage seems to at least only increase very slowly (if at all).

Is there anyone that is more familiar with the Node ecosystem and is able to provide a pointer to how best to debug this?
Or is this common behavior of Node that should be fine?

@azurecrash
Copy link

azurecrash commented Dec 28, 2022

Can confirm I am having the same issue here on the latest version of Homebridge and this plugin. Homebridge consumes approx 1GB of additional memory per day until the system becomes completely unresponsive and is physically restarted. Unsure of which plugin was the culprit, I was able to identify this one by process of elimination. Subsequently, we can see memory consumption is way more under control.

Screenshot 2022-12-28 at 3 04 25 PM

After the vertical blue line at right - which is where I disabled the plugin - the rate of mem consumption (slope of the light blue line) flattens. Prior, you can see several runs up and fall offs. The fall offs are reboots and service restarts, but the consumption of memory is at a standard rate.

Hope this helps

@prwhite
Copy link

prwhite commented Feb 15, 2024

Having the same issue. Just upgraded HomeBridge from older version to v1.7.0 including going to node 18.19.0 from 16.x. The homebridge process (not running any child bridges) grows for a couple of days and then I need to restart the process or else the system gets deeply into swap and ultimately becomes unresponsive. My setup was far more stable before these upgrades.

I attached Chrome dev tools to HomeBrige with NODE_OPTIONS --inspect.... After taking a couple heap snapshots 10 minutes apart, an overwhelming majority of the top "# Delta" and "Size Delta" entries appear to be related to this plugin. I attached some images of representative output from the dev tools session below. I can provide more info if it will help.

Of course, I changed more than one thing around the time of this version upgrade. I started sending MQTT messages to some clients when I get these PowerWall events. I suppose it's conceivable that through that new part of the flow something is getting unintentionally retained, although it's really straightforward stuff. I'm going to do some experiments to see if I can disable that part of my setup and see if there's a difference in memory behavior.

Pasted Graphic 3

Pasted Graphic 4

Pasted Graphic 8

Pasted Graphic 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants