BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parent is a performance hog

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Jens Larsen
Guest





PostPosted: Wed Apr 05, 2006 3:03 pm    Post subject: Parent is a performance hog Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.