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

node event listener warning #29

Closed
leonardo-k opened this issue Jul 25, 2019 · 6 comments
Closed

node event listener warning #29

leonardo-k opened this issue Jul 25, 2019 · 6 comments

Comments

@leonardo-k
Copy link

hi, that's a great library :)...but i have a problem using it :(
i'm wasn't able to find a method to remove the listeners from the internal interfaces of the library .
i'm working on an app that use bluez and bluetooth , and client can connect/disconnect very rapidly.
every time i connect a device a proxy obj is created and i read some property(mac address,name ecc ecc) , if the device is of a specific type, i put a call .on('PropertiesChanged') on the interface that i need to check.
after a few devices connection/disconnection , node tells a warn saying that i am adding too mutch event listeners for the same event ('PropertiesChanged event) but every time a device is removed i call removeListeners method on the all interfaces that listen to this event and i've got no errors ,also i destroy the interfaces with
iface=null
so ... there is a right way to remove obj and interfaces? what iam i doing wrong?

@acrisci
Copy link
Member

acrisci commented Jul 25, 2019

There's probably a memory leak somewhere in the library. I've gotten this warning as well. I never tested the case where objects come and go in a loop because that's not what I was doing with it.

I would like to see this fixed. It would help if you could post the warnings you are getting and a minimal test case to show the bug.

If you want to look into the library and see what's going on that would be helpful as well.

@leonardo-k
Copy link
Author

leonardo-k commented Jul 26, 2019

thanks for the quick answer :)
the warning i get is

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 {"path":"/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/player0","interface":"org.freedesktop.DBus.Properties","member":"PropertiesChanged"} listeners added. Use emitter.setMaxListeners() to increase limit

i think that this warn is thrown because of the listeners added to get the "properties-changed" events inside _initXml inside proxy-object.js file , is that possible?
at now i haven't a test case, ill try to make one and post it when i can
thanks again!

@leonardo-k
Copy link
Author

hello , i've modified the proxy-object file and add a new method to it , give it a try when you can

call this method when you don't need anymore a proxy object (it free the internal listeners).
using this method before destroy the proxy-object made the memory leak gone in my app

@leonardo-k
Copy link
Author

i've modified the function removeAllEventListeners , we can call this function when we are destroyng a proxy obj in order to release ALL the listeners for _signals , you are rigth, that's a better behaviour

@acrisci
Copy link
Member

acrisci commented Aug 2, 2019

@leonardo-k can you look at bd08f64 and see if latest master fixes your issue without #30?

@acrisci
Copy link
Member

acrisci commented Aug 12, 2019

I believe this is resolved by that commit.

@acrisci acrisci closed this as completed Aug 12, 2019
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

2 participants