[Lazarus] What effect does destroying threads have on system resources, especially with those making database connections?

Frank Church vfclists at gmail.com
Sat Feb 25 08:42:05 CET 2012


An application I have written connects to a remote Postgresql 8.3/8.4
database using Zeoslib components, but it has been timing out too often as
the network gets busy in a bursty mode. When the network times out,
restarting the app retrieves the data quickly, it is always available in
good time. The problem with some of the busier networks is that timeout
dialogs happen too often and it annoys the users who have to restart the
app.

My approach then is to run the database for displaying locally (which is
actually the original design) and fetch the data from the remote database
in background thread or in a background helper utility and insert it into
the local database, where the timeouts do not occur.

This creates 2 problems

1. When the connection times out

2. When the query itself times out.

Since handling connection timeouts and query timeouts can be fraught,what I
want to do is to create the whole process of retrieving the data in a
thread within the main program or in a helper utility, and destroying the
thread if it times out, but I can't be sure of what happens to the
resources created by the thread when it is destroyed, both in the program
code itself, the libpq libraries and on the server.

This may not be the best place for knowing what happens in the library or
on the server, but in the LCL and FPC will destroying the thread destroy
all the resources it creates?

Any ideas on what is likely to happen?


PS. I may not have posted here for some time due to critical work pressues,
but I have been lurking. I hope I have been missed ;)

PS2. I will be posting to the forums as well

-- 
Frank Church

=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120225/b8bf70f8/attachment-0002.html>


More information about the Lazarus mailing list