Comments (14)
What else would you expect? You're creating new channel streams every second, regardless of whether or not the callback has been executed and the 'exit' event has been emitted on the stream?
from ssh2.
Unfortunately, destruction of streams doesn't prevent memory leak. For example: https://dl.dropboxusercontent.com/u/3261328/testssh2.js
What should I do in order to execute a command every second using a single ssh connection?
from ssh2.
I would suggest wrapping your exec()
call into a separate function. Call it immediately on 'ready' and then on the stream's 'exit' event, do a setTimeout(doExec, 1000);
.
I would also suggest using some profiling tools to verify that there is in fact a leak and if so, where it is actually located.
from ssh2.
Thank you! I'll try to do as you suggest.
from ssh2.
Unfortunately, it didn't help.
I tried to run this code: https://dl.dropboxusercontent.com/u/3261328/testssh2_setTimeout.js
Here the results: https://dl.dropboxusercontent.com/u/3261328/testssh2_results.txt
Something like ssh.exec('watch -n1 cmd', function(err, stream) {...} )
runned once don't cause leakage.
from ssh2.
setTimeout(doExec(), 1000);
should be setTimeout(doExec, 1000);
EDIT: Additionally, you cannot expect it to execute exactly every second due to server latency and especially the routinely forced garbage collection.
from ssh2.
Oh, it's my mistake...
But the memory leak is still present: https://dl.dropboxusercontent.com/u/3261328/testssh2_results2.txt
you cannot expect it to execute exactly every second
It's not a big problem. In my task such precision is not important. And manual GC will be turned off in production.
from ssh2.
Any ideas?
from ssh2.
What do you think, it's a bug or my mistake?
I see the only solution at the moment: use the watch -n 1
from ssh2.
I have the same problem.
from ssh2.
After much digging (special thanks to heapdump) and investigation, I found the leak. It should now be plugged in the master branch.
Can both of you give it a try?
from ssh2.
Oh, thank u! It's much better now.
Unfortunately, leak is still there, but not so fast as before.
There is my tests: https://dl.dropboxusercontent.com/u/3261328/testssh2_results3.txt
from ssh2.
@VadimIpatov Let it run for much longer. I have been running it for several hours now (with manual full GCs to more easily ensure no leaks are present). During this time, it has been hovering around 3.17mb for the heap (process.memoryUsage().heapUsed) and 20mb for the rss (process.memoryUsage().rss).
from ssh2.
Yeah, you're right. It works! :)
Thank you!
from ssh2.
Related Issues (20)
- Not building in Cloudflare Workers HOT 1
- Issue Connecting to MongoDB via SSH Tunnel in Node.js HOT 1
- Issue/Suggestion :- Adding of maxEventListner on all the event HOT 4
- allow server to connect to forwarded agent from client HOT 1
- ecdsa-sha2-nistp256 private key support
- "Key auth required before password auth" error when connecting HOT 2
- READDIR hangs indefinitely HOT 12
- Specify `node-gyp` as a dependency. HOT 3
- SSH Client fails handshake when using publickey method HOT 7
- pm2 restart 0 No data is returned HOT 4
- Cannot find the bashrc source configuration when using ssh2 connect to the server HOT 3
- SSH version string "SSH-2.0-" is not accepted HOT 1
- Question: how to make gulp-ssh compatible with ssh2 HOT 5
- Handshake failed: no matching host key format HOT 2
- diffie-hellman-group-exchange-sha256 is very slow and take ~30 seconds HOT 5
- Error: Unsupported algorithm: arcfour256 HOT 1
- Error: (SSH) Channel open failure: open failed - upon third sftp operation, probably open connection leak HOT 1
- Generating ed25519 key pair can produce key pairs not readable by parseKey
- Access virtual machine on Teleport HOT 3
- "Instance unusable after fatal error" - Connection working for the first call, then failing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssh2.