 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jens Larsen Guest
|
Posted: Wed Apr 05, 2006 3:03 pm Post subject: Parent is a performance hog |
|
|
The following code takes ca minute to complete.
// Header file
TWinControl * Parent;
// Source file
__fastcall MyThread::MyThread(bool CreateSuspended, TWinControl *
parent)
: TThread(CreateSuspended), Parent(parent)
{
}
void __fastcall MyThread::Execute(){
for (int i = 0; i < 1000; i++)
{
TStringGrid * a = new TStringGrid(Parent); // owner
a->Parent = this->Parent; // comment out candidate
}
}
If I comment out the line with Parent assignment (in the Execute
method), the execution time falls to 0.5 second. The MyThread object is
created using a form's this-variable as parameter.
To my understanding, a VCL object uses it's Parent as a reference for
position. A VCL object's owner (in the constructor above) is
responsible for deletion. I make use of both attributes later on.
Is there a simple explanation for this behaviour? What can I do about
it?
C++ Builder 6 Pro
Thanks |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|