Archived Forum Post

Index of archived forum posts

Question:

SSHTUNNEL CPU Load 100%

Jun 04 '17 at 04:55

Hello!

I made a simple console application for port forwarding like plink. When i made 410 ports forwardings (run 410 copies of application) , everything is fine, CPU Load 0%. But when i made 450 ports forwardings, CPU Load is 100%. Each console application starts consuming 1-2% of the processor time. All port forwardings is working. Why is this happened?

program stineconnect;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,Chilkat_v9_5_0_TLB,classes;

  var

success: Integer;
tunnel: TChilkatSshTunnel;
sshHostname: PWideChar;
sshPort: Integer;
waitForThreadExit: integer;
info:tstringlist;
cmd:string;
port,user,ip:string;

begin

if paramstr(1)<>'' then
begin
  info:=tstringlist.create;
  info.Delimiter:='@';
  info.DelimitedText:=paramstr(2);
  user:=info[0];
  ip:=info[1];
  info.Clear;
  info.Delimiter:=':';
  info.DelimitedText:=paramstr(8);
  port:=info[1];
  info.Free;

tunnel := TChilkatSshTunnel.Create(nil);
tunnel.UnlockComponent('Anything for 30-day trial.') ;

sshHostname := pchar(ip);
sshPort := strtoint(paramstr(4));

  success :=tunnel.Connect(sshHostname,sshPort);

if (success <> 1) then
  begin
   Exit;
  end;

  success := tunnel.AuthenticatePw(pchar(user),pchar(paramstr(6)));
if (success <> 1) then
  begin

    Exit;
  end;
  tunnel.DynamicPortForwarding:=1;
 success := tunnel.BeginAccepting(strtoint(port));
if (success <> 1) then
  begin
    Exit;
  end;

   ReadLn(cmd);
end;
end.

Answer

I tried to redirect ports using OpenDirectTcpIpChannel (TChilkatSsh and TChilkatSshTunnel), and through DynamicPortForwarding. Everywhere the same problem, up to 410 copies everything is stable, the memory is static, low CPU usage. When I run 450 copies or more, the console applications go crazy, memory in the task manager starts to jump, 100% CPU usage.