[fpc-pascal] Re: 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 15:56:18 CEST 2010


On 16 Oct 2010, at 15:46, Martin Schreiber wrote:

> Jonas Maebe wrote:
> 
>> 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.
>> 
> 
> Will it crash if it is empty as in TObject?

The contents of AfterConstruction don't matter. If the instance is freed before the constructor had a chance to call AfterConstruction, the self pointer won't be valid anymore in the constructor and hence the call to AfterConstruction may crash.

Note that in svn trunk, self can no longer be freed before AfterConstruction has been called because of the fix from http://bugs.freepascal.org/view.php?id=16884.


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


More information about the fpc-pascal mailing list