Al Boldi ha scritto:
To get the leak on fpc2.0.2 you have to change your code like this:
for I := 0 to high(BugArray) do begin
t1 := BugArray[I];
t1.Terminate;
- t1.WaitFor;
write ('.'); // this causes intermittent idles causing the leak
if not Ft then begin
sleep(50);
t1.Free;
end;
end;
...and...
writeln('WaitFor? [y/N]');
+ t1.Terminate;
readln(ans); // you need to idle after terminate to see the leak
- t1.Terminate;
if ans='y' then begin
if not Ft then begin
t1.WaitFor;
writeln('OS thread memory released.');
end;
end else
writeln('OS thread memory left dangling.');
Also note that when you TThread.Free a running thread it will do an implied
Terminate and WaitFor, and therefore works without leaking on fpc2.0.2.
Well, the advantage of fpc 2.2.0 is that it's more consistent. :-)
Whatever you do (write or no write, sleep(x) or no sleep,
FreeOnTerminate or not, just Free without Terminate and WaitFor, or
Terminate, WaitFor and Free) the leakage is always the same :-)
But as I've found some old postings about thread memory leaks in Linux,
I'd like to make some comparative tests to ascertain if the problem
comes from fpc or from linux kernel.
BTW could you refresh my memory? What kernel and libc are you running with?
Regards,
Giuliano
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives