[fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Oct 16 14:04:54 CEST 2010


On 16 Oct 2010, at 13:57, Benedikt Schindler wrote:

>>> - FreeOnTerminate should be gone, (meaning no way to actively call
>>> TThread.Destroy from another thread, a thread gets destroyed
>>> automatically when it leaves its execute method)
>>> (IIRC FreeOnTerminate was even set to False by the default
>>>  constructor, so you had the choice of either using the default
>>>  or introducing a race condition by setting it after the
>>>  "inherited Create" - which starts the execute.)
>> 
>> This problem has been solved with http://bugs.freepascal.org/view.php?id=16884
> 
> But i think also the "bug" report you are linking to, shouldn't be a fpc
> bug. It is more a programmer bug. As programmer i have to know at which
> time i call the create methode of my TThread.

He cannot. If freeonterminate=true, then even if you call "inherited create(false)" as the very last statement of your constructor, the thread may already have finished running and freed itself before AfterConstruction is called. The AfterConstruction call will then crash.


Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20101016/4db82300/attachment.html>


More information about the fpc-pascal mailing list