thenewwazoo / homebridge-lutron-caseta-leap

Homebridge support for Lutron Caseta Smart Bridge 2
Apache License 2.0
77 stars 27 forks source link

Memory Leak #15

Closed zackwag closed 2 years ago

zackwag commented 2 years ago

Describe The Bug: Homebridge is returning an error during startup saying a memory leak has been encountered.

To Reproduce: Startup Homebridge.

Expected behavior: No error emitted

Logs:

(node:80454) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unsolicited listeners added to [LutronCasetaLeap]. Use emitter.setMaxListeners() to increase limit

Plugin Config:

        {
            "name": "Lutron",
            "secrets": [
                {
                    "bridgeid": "",
                    "ca": "-----BEGIN CERTIFICATE-----",
                    "key": "-----BEGIN PRIVATE KEY-----",
                    "cert": "-----BEGIN CERTIFICATE-----"
                }
            ],
            "platform": "LutronCasetaLeap"
        }

Environment:

rcoletti116 commented 2 years ago

I was just about to open an issue about this and came here and found this one. Interesting timing. I've been having a memory leak as well and working to find the root. I test individual plugins and narrowed it down to this one. I didn't catch the error in the logs though.

thenewwazoo commented 2 years ago

Interesting. If you could enable debug logging, that would help, so I can see what’s being constructed.

zackwag commented 2 years ago

Sure. I've attached my log. Please ignore all the Homebridge Somneo and Homebridge Connected Device Occupancy. In debug mode, I log a lot of data homebridge.log .

thenewwazoo commented 2 years ago

Thanks for the report. Each device subscribes to receive unsolicited messages from the hub, and that has a default limit of 10. There's not actually a leak there (not related to that warning, anyway). @rcoletti116 how are you observing the memory leak?

rcoletti116 commented 2 years ago

@thenewwazoo I noticed my memory usage growing over time, eventually crashing my instance. I began monitoring and testing each plugin. Using htop and other tools on my pi I watched as the %mem grew for my child bridge for this plugin from 4% to 8% over a couple of hours. Then I disabled the plugin to test.

thenewwazoo commented 2 years ago

Hm. Can you open a new issue with the data you've collected, version info, and a listing of the devices you have (just a count is fine)?