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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Vinzent Höfler
On Sat, 16 Oct 2010 17:42:03 +0200, Luca Olivetti <[hidden email]> wrote:

> Al 16/10/10 16:57, En/na Vinzent Höfler ha escrit:
>
>>
>> Well, the usual implementation of an externally called "Destroy" is
>>
>> - first a call to the Terminate method
>> - then a WaitFor()
>
> Nope, I avoid the WaitFor.

Nice for you, but I'd rather avoid polling solutions.

> I usually do a
>
>    while not FFinished do
>      CheckSynchronize(100);

Check again. You can't even access FFinished from a foreign thread.


Vinzent.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

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

Luca Olivetti-2
Al 16/10/10 17:49, En/na Vinzent Höfler ha escrit:

> On Sat, 16 Oct 2010 17:42:03 +0200, Luca Olivetti <[hidden email]> wrote:
>
>> Al 16/10/10 16:57, En/na Vinzent Höfler ha escrit:
>>
>>>
>>> Well, the usual implementation of an externally called "Destroy" is
>>>
>>> - first a call to the Terminate method
>>> - then a WaitFor()
>>
>> Nope, I avoid the WaitFor.
>
> Nice for you, but I'd rather avoid polling solutions.

I use that only for threads I start at the beginning of the app and
terminate at the end, so polling isn't a big issue.
In fact I break the operation in two: first I Terminate all running
threads, then I check if they're finished (so that they all have time to
stop in parallel).
It's not strictly necessary since the OS will clean up everything
afterwards, but I prefer to do things properly.

>
>> I usually do a
>>
>> while not FFinished do
>> CheckSynchronize(100);
>
> Check again. You can't even access FFinished from a foreign thread.

I can (FFinished is a private member defined by me, and Destroy, being a
method of the same class, can access private members).

Bye
--
Luca
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal