I have a problem with a slowing down of my code execution if I use such classes as TText, TEllipse etc. to show somethingon on the TCanvas in a loop. There is simple example of the code below. Also the consumption of the CPU time increases with a time. If I declare TText variable inside loop (commented out line in the example) the code is executed much faster and doesn’t slow down. The code behave the same way under interpreter and compiler execution. The same problem I have with a more complicated code where I need to declare such variables only outside loops. Does anybody know a reason and how to solve a problem.
Thank you,
Oleg Kalekin.
void test()
{
TCanvas c(“c”,“test”,200,200);
int i=1;
char t[20];
TText txt(0.5,0.5,"");
while(i>0) { i++;
//TText txt(0.5,0.5,"");
sprintf(t,"%d",i);
txt.SetTextSize(0.1);
txt.SetText(0.5,0.5,t);
txt.Draw();
c.Update();
}
}