Slowing down of the execution with TText etc. in a loop

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,"");

This is the expected behaviour. You keed adding new objects to the list of objects in the pad. Read the chapter about graphics in the Users guide or shorter the Howtos like


Those, I do Draw() once before a loop. It works, thank you.