I have an application which requires very long term execution. It creates a series of SshCommand objects (Each with a specific command) then executes those (using command.execute()) once every few seconds for multiple weeks. The string results are used to populate various parsers and GUI elements.
I have not been able to isolate the reasons, but what I see are millions of left over ChannelSession objects resulting in a system crash (Out of memory).
I suspect I simply am not using the library correctly since there's no mention of this in recent discussions. Is there a good reference example of how to use the library to perform long term polling (Via SshCommand)?
Generally, my technique is:
If my technique is correct, why is ChannelSession not being garbage colledted after each Execute()? The EndExecute() method looks like it should be Closing the channel:
Robert
I have not been able to isolate the reasons, but what I see are millions of left over ChannelSession objects resulting in a system crash (Out of memory).
I suspect I simply am not using the library correctly since there's no mention of this in recent discussions. Is there a good reference example of how to use the library to perform long term polling (Via SshCommand)?
Generally, my technique is:
- Create a ConnectionInfo object conn
- Create a SshClient(conn) object client
- Call client.Connect()
- Add SshCommand (s) to client using client.CreateCommand()
- Periodically execute the SshCommands using command.Execute()
-
When the program is done, call client.Disconnect() and client.Dispose()
If my technique is correct, why is ChannelSession not being garbage colledted after each Execute()? The EndExecute() method looks like it should be Closing the channel:
public string EndExecute(IAsyncResult asyncResult)
{
if (this._asyncResult == asyncResult && this._asyncResult != null)
{
lock (this._endExecuteLock)
{
if (this._asyncResult != null)
{
// Make sure that operation completed if not wait for it to finish
this.WaitHandle(this._asyncResult.AsyncWaitHandle);
if (this._channel.IsOpen)
{
this._channel.SendEof();
this._channel.Close();
}
this._channel = null;
this._asyncResult = null;
return this.Result;
}
}
}
Thanks,Robert