[Lazarus] Memory leak in TThread class

Luca Olivetti luca at wetron.es
Thu Oct 7 09:31:48 CEST 2010


En/na Sergei Gorelkin ha escrit:
> Marcos Douglas wrote:
> 
>> Well, the problem was fixed.
>> Bug reporter: http://bugs.freepascal.org/view.php?id=16884
>> Solution: http://cia.vc/stats/project/fpc/.message/b8ef19
>>
> Unfortuately, not. Issue #16884 was a race condition which was causing 
> the thread to start executing before it was completely initialized by 
> its constructor. The current issue is a resource leak that happens when 
> a TThread is created and then destroyed before executing any thread code.

I don't see the bug there: as soon as you call "inherited create(false)" 
you know that the thread can start executing, that's the point of 
creating it *not* suspended.
If you want to be sure that the constructor has initialized everything, 
either call "inherited create(false)" as the last instruction of the 
constructor or use "inherited create(true)" and later call "resume".
Oh, well, maybe I'm just used to defensive programming.

Bye
-- 
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004 (Ext.133)  Fax +34 93 5883007




More information about the Lazarus mailing list