Al Boldi ha scritto:
Al Boldi wrote:
Micha Nelissen wrote:
Al Boldi wrote:
I think the race comes in when you have two competing threads wanting
to synchronize the the main thread. It just hangs.
Are you sure? This should work properly. Can you provide example (in a
bugreport)?
Well, it's not easily repeatable, and seems to be very OS dependent. On
linux, I work around this problem by inserting a sleep(0) just before the
synchronize.
But there is another problem, it seems FreeOnTerminate doesn't actually
free the memory on exit, unless the main thread actually waits for it to
terminate, and this is on linux again. Can you confirm this?
I played with this some more, and it turns out that not only is
FreeOnTerminate completely broken but Free only frees the OS-thread memory
if the thread is still running or is preceded by a WaitFor. This is on
fpc2.0.2/linux. Maybe this has been fixed in 2.2.0?
Below is the test-code.
Can somebody confirm this on other platforms/fpcVersions.
I've made some quick tests, with what I have ready at hand and with my
test app. Not so different from yours, except that it allows me more
options. Platform Linux, fpc 2.0.4 and 2.2.0, Lazarus.fixes and Lazarus
trunk latest svn. Widgetset gtk1.
With fpc 2.0.4, FreeOnTerminate leaks memory whatever I've tried.
With fpc 2.2.0, using Synchronize, I've been unable to get rid of memory
leaks if the thread is terminated within an OnClose event.
If the thread is terminated before closing the form, it behaves properly.
With fpc 2.2.0, if I don't use Synchronize, but rather a message queue
processed by the OnIdle handler, then I don't experience any memory
leak, whatever is the thread termination.
My conclusion: fpc 2.0.4 has almost certainly some bug on
FreeOnTerminate. In many cases it segfaults, meaning, I guess, that
there's some NilAndFree in place of FreeAndNil :-)
With fpc 2.2.0 it's harder to tell at first glance, but one would say
that the problem is on Lazarus side, because the fpc rtl Syncronize
provide just a thread safe frame, and leaves all the work to the main
thread loop.
Synchronize is heavily widgetset dependent. That's why I only report
gtk1 results. With gtk2 I've met inconsistent results from one revision
to the next, with qt synchronize for me doesn't work at all.
Giuliano
--
Giuliano Colla
Whenever people agree with me, I always feel I must be wrong (O. Wilde)
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives