Multiple WinSCP.exe processes

Advertisement

Rob5624
Joined:
Posts:
5

Multiple WinSCP.exe processes

I created some FTP routine as part of a Visual Basic application that calls WinSCP three times during runtime.
Every time a call to WinSCP is initiated via the WinSCPnet.dll a new "WinSPC.exe" process pops up connected to my application (i.e. as child processes).
I would have expected that a single process would pop up, or at least that every call would re-use the existing process.
What makes things worse is that at the moment my application stops the "WinSCP.exe" processes keeps on running...

Looking for a way to prevent this from happening, I don't like the idea of multiple ghost processes in memory...

Thanks in advance!

Reply with quote

Advertisement

Rob5624

Added the close method to the tool, now only one ghost "WinSCP.exe" remains in memory... still not the solution I look for.
Dispose method results in the same as the close method... every time my application closes a single "WinSCP.exe" process remains in memory, so after ten runs the process is there 10 times...

Reply with quote

Rob5624
Joined:
Posts:
5

Finally added the following VB code to find and kill WinSCP.exe processes started by my application:

Imports System.Management

Dim myId = Process.GetCurrentProcess.Id
Dim selectQuery As SelectQuery = New SelectQuery("Win32_Process", "Name = 'WinSCP.exe'")
Dim searcher As New ManagementObjectSearcher(selectQuery)
For Each proc As ManagementObject In searcher.Get
If (proc("ParentProcessId") = myId) And (proc("name") = "WinSCP.exe") Then Process.GetProcessById(proc("ProcessId")).Kill()
Next

Not the most efficient, but it works.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Please attach a full session debug log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.DebugLogPath. Submit the log with your post as an attachment. If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Rob5624
Joined:
Posts:
5

Hi Prykril,

Thanks for the suggestion... helped me to find the cause for the "ghost"...
I added the "dispose" to the session I used to update data... however I forgot to add it to a second session which I used to check the initial state of a remote folder... :-(
So I added the dispose there as well and now the ghost process also disappears!

(I was able to get 2 log files where I expected to get 3 by adding the microseconds to the logfile)

So issue solved:-)

Reply with quote

agFinder
Joined:
Posts:
2

Solved problem with IDisposable

I was getting dozens of WinSCP processes and eventually a 'connection failed' error. Implementing IDisposable in the SCP class then calling .Dispose() after each use solved the problem.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Solved problem with IDisposable

agFinder wrote:

I was getting dozens of WinSCP processes and eventually a 'connection failed' error. Implementing IDisposable in the SCP class then calling .Dispose() after each use solved the problem.
The Session class implements IDisposable:
https://winscp.net/eng/docs/library_session#syntax
Note the use of using in all .NET examples for WinSCP .NET assembly.
One example out of many: https://winscp.net/eng/docs/library#example

Reply with quote

Advertisement

You can post new topics in this forum