-
Notifications
You must be signed in to change notification settings - Fork 285
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
Can't release EventEmitter hooked to fs.ReadStream (Memory leak) #3289
Comments
I don't familiar with lib you used here. Just an random idea, could this be related to that |
Thank you for the reply and suggestion. |
|
thanks for the hint - stumbled over this difference in the node.js doc, but could not make sense of it yet - as mentioned, I'm rather new to js. |
As promised, short update: I tried two things:
A similar issue seems to be described here: I am at a loss here, but as mentioned earlier, in my case the FD is only opened at boot and closed at shutdown once, so the risk is limited to see any issue. However, if a user would do a lot of configuration changes in one session, it would probably create issues, since the FD would be (improperly) closed and reopened at every reconfig. So not nice but low risk. |
I looked into this more and still could not get it to work. But I found a workaround using the hint that @kuba-orlik gave in nodejs/node#15439: Instead of using the combination of
to create the handle. You can then later kill the resource by calling
In my case this works and seems to solve my problem. |
I read data from a dtoverlay device. Reading works fast and reliable, but I cannot properly clean up resoureces when the script ends:
Ctrl-C
.sudo dtoverlay -r
I get a Kernel warning about a potential memory leak.I tracked it down to a problem in an npm module I use (input-event). There seems to be a FSREQWRAP handle remaining somewhere, that causes both issues. I stripped down the module to the base and have the exact line that causes the fail. It seems to be related to an EventListener attached to an fs.Readstream object.
Below is the stripped down code snippet with the line causing the fail highlighted. Removing the listener is not helping.
Any ideas? Is this a bug or is the implementation wrong? Despite experience in other languages, I am new to JS and really have difficulties spotting the issue here.
The
why-is-node-running
module reports 2 unreleased handles (one of them is from the timeOut I use to triggerwhy-is-node-running
but the other is generated by the line indicated above.I'm at a loss - ideas welcome...
The text was updated successfully, but these errors were encountered: