[Lazarus] Memory leak in TThread class
Marcos Douglas
md at delfire.net
Tue Oct 5 15:35:22 CEST 2010
On Tue, Oct 5, 2010 at 9:50 AM, Luca Olivetti <luca at wetron.es> wrote:
> En/na Marcos Douglas ha escrit:
>>
>> On Tue, Oct 5, 2010 at 9:40 AM, Luca Olivetti <luca at wetron.es> wrote:
>>>
>>> En/na silvioprog ha escrit:
>>>>
>>>> Hi folks,
>>>>
>>>> I detected a small leak in the TThread class. I made a simple test and I
>>>> sending in attached (or http://pastebin.com/aWNuHyDQ). To reproduce the
>>>> leak, just open and close the demo.
>>>
>>> That's probably because the thread has no chance to run (you create it
>>> suspended and never resume it).
>>> If you create it with suspended=false or resume it right after creating
>>> it,
>>> there's no leak.
>>
>> Even that, I consider this a bug, don't you?
>
> I'm not sure it is: when I create a thread is because I need it to run, if
> it doesn't have to run I simply don't create it.
> In the constructor I usually delay starting the thread until all members
> are correctly initialized (i.e. "inherited create(true); foo:=Tfoo.create;
> resume"), but afterwards it has to run.
> If you forget to, say, free objects in a thread, it will cause a memory leak
> but it's not a bug, this case is analogous: you create a thread but forget
> to start it.
IMHO, the act of creating and destroying it should not be related to running.
Marcos Douglas
More information about the Lazarus
mailing list