ebaauw / homebridge-rpi

Homebridge plugin for Raspberry Pi.
Apache License 2.0
308 stars 18 forks source link

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. #48

Closed marcelo-lara closed 4 years ago

marcelo-lara commented 4 years ago

Hi! I'm using 8 gpios to control relays, but I don't know where to set the "emitter.setMaxListeners()" Here's the log. Thanks!

homebridge.log

[8/15/2020, 19:29:13] Homebridge is running on port 51131.
[8/15/2020, 19:29:14] [RPi] localhost: connected to localhost:8888
[8/15/2020, 19:29:14] [RPi] localhost: Raspberry Pi 4B v1.1 (BCM2711, 2GB) - 100000004460660F
[8/15/2020, 19:29:14] [RPi] localhost m2-io12: set Serial Number to "100000004460660F-12"
[8/15/2020, 19:29:14] [RPi] localhost m2-io12: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m2-io12: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m2-io12: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m2-io16: set Serial Number to "100000004460660F-16"
[8/15/2020, 19:29:14] [RPi] localhost m2-io16: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m2-io16: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m2-io16: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m2-io20: set Serial Number to "100000004460660F-20"
[8/15/2020, 19:29:14] [RPi] localhost m2-io20: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m2-io20: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m2-io20: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m2-io21: set Serial Number to "100000004460660F-21"
[8/15/2020, 19:29:14] [RPi] localhost m2-io21: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m2-io21: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m2-io21: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m3-io23: set Serial Number to "100000004460660F-23"
[8/15/2020, 19:29:14] [RPi] localhost m3-io23: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m3-io23: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m3-io23: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m3-io24: set Serial Number to "100000004460660F-24"
[8/15/2020, 19:29:14] [RPi] localhost m3-io24: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m3-io24: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m3-io24: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m3-io8: set Serial Number to "100000004460660F-8"
[8/15/2020, 19:29:14] [RPi] localhost m3-io8: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m3-io8: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m3-io8: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m3-io7: set Serial Number to "100000004460660F-7"
[8/15/2020, 19:29:14] [RPi] localhost m3-io7: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m3-io7: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m3-io7: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m4-io6: set Serial Number to "100000004460660F-6"
[8/15/2020, 19:29:14] [RPi] localhost m4-io6: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m4-io6: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m4-io6: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m4-io13: set Serial Number to "100000004460660F-13"
[8/15/2020, 19:29:14] [RPi] localhost m4-io13: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m4-io13: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m4-io13: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m4-io19: set Serial Number to "100000004460660F-19"
[8/15/2020, 19:29:14] [RPi] localhost m4-io19: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m4-io19: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m4-io19: set dutyCycle to 0
[8/15/2020, 19:29:14] [RPi] localhost m4-io26: set Serial Number to "100000004460660F-26"
[8/15/2020, 19:29:14] [RPi] localhost m4-io26: set Manufacturer to "homebridge-rpi"
[8/15/2020, 19:29:14] [RPi] localhost m4-io26: set Model to "Light"
[8/15/2020, 19:29:14] [RPi] localhost m4-io26: set dutyCycle to 0
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 5 listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 83 listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
[8/15/2020, 19:29:15] [RPi] localhost m2-io12: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m2-io16: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m2-io20: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m2-io21: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m3-io23: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m3-io24: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m3-io8: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m3-io7: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m4-io6: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m4-io13: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m4-io19: set On to false
[8/15/2020, 19:29:15] [RPi] localhost m4-io26: set On to false
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 83 listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 83 listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 83 listeners added to [PigpioClient]. Use emitter.setMaxListeners() to increase limit
(node:2305) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to 
[PigpioClient]. Use emitter.setMaxListeners() to increase limit
ebaauw commented 4 years ago

Hi! I'm using 8 gpios to control relays

According to the log, you have 12 light devices? These use PWM to dim the LEDs and are unsuitable to drive relays. You need to use switch devices for those. Also, the PWM values need to be polled, whereas the on/off values are received through push notifications. See the Wiki.

I don’t think there actually is a memory leak. Homebridge RPi doesn’t throttle the asynchronous requests to the pigpiod server. With your configuration, it’s sending 12 requests in parallel, to set the initial duty cycle, and then to poll the duty cycles. Each request adds a one-time listener for the response event (5 is for setting the duty cycle, 83 for querying it) and error event. I’m not sure if increasing the expected number of listeners is the right course here, I think throttling the requests to pigpiod is.

Note that the message is just a warning, Homebridge RPi continues to function normally.

Note to self: same will probably happen with this many servo devices.

ebaauw commented 4 years ago

Fixed in v1.1.14.

marcelo-lara commented 4 years ago

Fixed in v1.1.14. Great!! thanks!