Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-08

TProcess stack size

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frank Poretzky

Hi,

in MS Windows is there a way to increase stack size for an executable run through TProcess? For portability reasons I tried to migrate from CreateProcess to TProcess, but when executing more complex operations of the called program it now aborts due to a memory shortage though simpler tasks in the same program run correctly. I've already set the project's heap (-Ch) and stack size (-Cs) to high values.

  AProcess.Options := [poUsePipes, poNoConsole];
  AProcess.PipeBufferSize := 2048;
  AProcess.ShowWindow := swoNone;
  AProcess.CurrentDirectory := ExtractFilePath( ExeStr);
  AProcess.Executable := ExeStr;
  AProcess.Parameters.Text := ParStr;
  AProcess.Execute;

makes problems whereas with

  CreateProcess( nil,
                 PChar( ExeStr + ' ' + ParStr),
                 @SecAttribs, nil,
                 true,
                 CREATE_NEW_CONSOLE or CREATE_SEPARATE_WOW_VDM or
                 CREATE_NEW_PROCESS_GROUP or NORMAL_PRIORITY_CLASS,
                 nil,
                 PChar( ExtractFilePath( ExeStr)),
                 StartInfo, ProcInfo);

as well as run directly from the commandline it works properly.

(fpc 2.7.1 svn trunk rev. 28506 - i386-win23-win32/win64)

Thanks

Frank

Michael Van Canneyt
to Frank Poretzky
Frank Poretzky wrote
Hi, in MS Windows is there a way to increase stack size for an executable run through TProcess?

Not that I am aware of.

Show quoted text 21 lines
For portability reasons I tried to migrate from CreateProcess to TProcess, but when executing more complex operations of the called program it now aborts due to a memory shortage though simpler tasks in the same program run correctly. I've already set the project's heap (-Ch) and stack size (-Cs) to high values. AProcess.Options := [poUsePipes, poNoConsole]; AProcess.PipeBufferSize := 2048; AProcess.ShowWindow := swoNone; AProcess.CurrentDirectory := ExtractFilePath( ExeStr); AProcess.Executable := ExeStr; AProcess.Parameters.Text := ParStr; AProcess.Execute; makes problems whereas with CreateProcess( nil, PChar( ExeStr + ' ' + ParStr), @SecAttribs, nil, true, CREATE_NEW_CONSOLE or CREATE_SEPARATE_WOW_VDM or

the CREATE_SEPARATE_WOW_VDM is something that does not exist in TProcess, but since it is used to control 16-bit processes, I doubt this is the cause of your problem.

Show quoted text 6 lines
CREATE_NEW_PROCESS_GROUP or NORMAL_PRIORITY_CLASS, nil, PChar( ExtractFilePath( ExeStr)), StartInfo, ProcInfo); as well as run directly from the commandline it works properly.

Does the program create output ?

If so, are you reading the output from the pipes ? If not, this is most likely your problem. When the I/O buffers are full, The program will block till you read the output and thus free the I/O buffers...

Michael.

Frank Poretzky
to Michael Van Canneyt

Hi Michael,

you wrote 16 lines
On Fri, 22 Aug 2014, Frank Poretzky wrote: > Hi, > > in MS Windows is there a way to increase stack size for an executable > run through TProcess? Not that I am aware of. > For portability reasons I tried to migrate from > CreateProcess to TProcess, but when executing more complex operations of > the called program it now aborts due to a memory shortage though simpler > tasks in the same program run correctly. I've already set the project's > heap (-Ch) and stack size (-Cs) to high values. > > AProcess.Options := [poUsePipes, poNoConsole];

The problem was located here --------^^^^^^^^^^^
No console, no pipe output (sometimes).

Thanks Michael

Frank