|Subject:||Re: Indy components on the fly vs. on the form?|
|Posted by:||Martin James (mjames_falc…@dial.pipex.com)|
|Date:||Tue, 30 Sep 2003|
"Andrew Fiddian-Green" <andrewfg at zugernet dot ch> wrote in message
news:167C99E3D680E240andrewfg at zugernet dot ch...
> My application uses IdHTTP client components for several different
> functions. Currently I create the components on the fly in code. But I
> notice that Indy executes stack initialisation code only when the first
> component is created. So I suppose that if I create and destroy many Indy
> components on the fly this initialisation code may be run rather often. =>
> Is there a performance hit?
I'm not sure why, but serveral Indy components seem to take a
human-noticeable amount of time to create. Probably, it's just because of
unavoidable complexity & delays in winsock.
I ususally manage to avoid the problem by pooling, rather that destroying,
such components. If you've done with one, shove it onto a Tlist or Tqueue.
If you want one, try getting one from the pool first & only create one if
the pool is empty. Pool get/put methods need a critical section if you have
threads, (in which case, you might be able to pool the whole thread, TidHTTP
and all). Continual create/free of complex components is often just a an
easily avoidable waste of CPU/time. Pooling also mitigates create/free
leakages. *Note for Chad* I'm not saying TidHTTP leaks! Code around it
may do so, however, as I have occasionally proved in my apps :)
Indy components on the fly vs. on the form? posted by Andrew Fiddian-Green on Tue, 30 Sep 2003