Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi + Indy causes high page fault and RAM usage

I experience one weird problem.

I use Delphi and Indy to upload and backup some files. It runs just fine on many computers (Win7 64bit, WinXP) . CPU usage is less then 1% and max. 20MB in RAM.

But there is one computer (Win 2008 R2) where it is problematic and I can't find out why. CPU usage is 5-20%, it takes 100MB+ in RAM and it increases a lot. Furthemore "page fault" rises a lot, eg. 100 000 every second (not increasing on my computer)

Code is very simple

var
  IdHTTP: TIdHTTP;
  IdPostData: TIdMultiPartFormDataStream;
  sResponse: string;
begin
  IdHTTP := TIdHTTP.Create(nil);
  IdPostData:=TIdMultiPartFormDataStream.Create;

  try
    IdPostData.AddFile('file', 'C:\data.dat', '');

    sResponse:=IdHTTP.Post('http://web.com', IdPostData);

    ShowMessage(sResponse);
  finally
    IdHTTP.Free;
    IdPostData.Free;
  end;
end;

Does anybody have any idea why "page fault" increases that a lot? Is it possible that there is some hardware issue? How to find it?

like image 501
smooty86 Avatar asked Feb 05 '14 17:02

smooty86


1 Answers

just put "IdHttp := nil; IdPostData:=nil; sResponse := 'Ok'; " before "try" clause and try again

--reviewed-- Changed your code a little bit

procedure SendFile;
var
  IdHTTP: TIdHTTP;
  IdPostData: TIdMultiPartFormDataStream;
  sResponse: string;
begin
  sResponse := 'OK';
  IdHTTP := TIdHTTP.Create(nil);
  IdPostData:=TIdMultiPartFormDataStream.Create;
  try
    IdPostData.AddFile('C:\data.dat', 'data.dat', '');

    IdHTTP.Post('http://www.yahoo.com', IdPostData);

    ShowMessage(sResponse);
  finally
    IdHTTP.Free;
    IdPostData.Free;
  end;
end;
like image 138
3 revs Avatar answered Sep 21 '22 14:09

3 revs