-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Possible ssh2Stream._channels[chan]
leak (v0.8.9)
#1012
Comments
The reserved channel numbers are deleted when the channels themselves are closed. Judging by the (large number of) |
Actually, upon further review, I think I may see what's happening here..... |
Thanks for the report! |
Thank you for your attention! So the fix is only available in the latest unreleased version? Is it recommended to update to the latest version and how to migrate to the latest version? If not, when can I safely delete those leaked channels (as a workaround at the moment)? |
It will be included in the upcoming v1.0.0 release. I will probably do that release in the next couple of days or so. |
Regarding changes between v0.8.x and what will be v1.0.0, you can find most of them here: #935 |
Sounds great! Thanks! |
I am forwarding out TCP connections from remote system to local system. A few hundreds of connections were established and ended (the
end
event emitted). However, the._channels
also had hundreds of properties with numerical keys andtrue
as their values. It looks something likeAfter searching for all accesses to
_channels
in the code and some inspection, I found it could be a leak. Here are the related code snippets for your easy reference.Assignment to
_channels[*]
:https://github.com/mscdex/ssh2/blob/v0.8.x/lib/client.js#L1508
Deletion of
_channels[*]
:https://github.com/mscdex/ssh2/blob/v0.8.x/lib/client.js#L1199
Call chain of deletion:
https://github.com/mscdex/ssh2/blob/v0.8.x/lib/client.js#L338
https://github.com/mscdex/ssh2/blob/v0.8.x/lib/client.js#L1156
It seems these properties will be removed only when the underlying SSH connection is closed:
https://github.com/mscdex/ssh2/blob/v0.8.x/lib/client.js#L313-L338
This will eventually exhaust the memory because in my case the port forwarding is intended to be persistent.
The text was updated successfully, but these errors were encountered: