Am 11.10.2011 15:44, schrieb Vincent Snijders:
Hi,

Is it allowed to execute a TProcess object more than once? And if yes,
different command lines be used?

The reason I ask is issue 19997, each invocation of the compiler in
Lazarus leaks a process handle and a thread handle on windows. (not
tested on other OS-es).

If is it allowed to re-use TProcess object, how can it be done without
leaking handles?

A quick look at the implementation of TProcess let's me come to the conclusion that it's not allowed to reuse TProcess. If you look at TProcess.Destroy you'll see that only there "FreeStreams" and "CloseProcessHandles" is called. So if you create a new process new streams and new handles (on Windows) are created (so you are not only leaking handles, but also streams if you use "poUsePipes").

You might be able to workaround this by introducing a descendant of TProcess and adding a method "Reset" which calls "CloseProcessHandles" and frees the streams (you can't use "FreeStreams", because it's private, but the streams are protected).

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to