[fpc-pascal] Re: 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 17:12:51 CEST 2010


On 16 Oct 2010, at 17:13, Martin Schreiber wrote:

> Jonas Maebe wrote:
> 
>> 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.
>> 
> What are the conditions that it crashes if "self" is not used in
> AfterConstruction? Is there hidden code beside of AfterConstruction after
> Create() which uses "self"?

AfterConstruction is called from within Create, after all user code in the constructor has been executed (and if no exceptions occurred). And the call to AfterConstruction uses self, because AfterConstruction is a virtual method (so you have to load self.vtable[afterconstruction_index]).

> As written before it does not crash in
> tmsethread which does not inherit from FPC TThread.

You're just getting lucky in your tests.


Jonas


More information about the fpc-pascal mailing list