This is an area where I have never found one answer solves all.

The main thing to watch is memory leaks - we use Sleuth Codewatch and it has saved us 
a couple of times.

With multithreading you have to add critical sections and inuse flags.  If the ojects 
are shortuse you can envelope the acquire-drop in one critical section, but normally 
you have to give the acquire function the ability to instantiate extra copies if 
necessary.

The simplest way I have found is to write the "pooling" into the object itself by 
overwriting the Create and Free methods to maintain an instantiated object in a unit 
variable. This  involves minimal additional code and means that you can add the 
additional functionality at any time without affecting the code in the rest of the 
application.  It also makes it easier to do side by side tests to see the result of 
maintaining a static copy of a particular object.

Just make sure that the Create method resets all properties to default and calls any 
OnCreate events.

Stephen

-----Original Message-----
From: Ben Taylor [mailto:[EMAIL PROTECTED]]
Sent: Friday, 23 August 2002 10:38 a.m.
To: Multiple recipients of list delphi
Subject: [DUG]: 24/7 application design


hi,

does anyone have thoughts/experience on apps that run 24/7, creating /
destroying around 20 objects/sec (different classes). i'm wondering if
i should take the time to implement a component pool (eg
aObj:=pool.acquire(TmyComp) ), which would eliminate the memory
churn/fragmentation i'm concerned about. however this does increase
complexity/ chances of bugs etc..

the other alternative is that i change to a more static design, but
from a design point of view i dont want to do that.. :-)

i'll be running a test at some point, but it could take a week or 2 to
get my answer :-)

comments?

thanks,
ben
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to