المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Why it doesn't eat SYSTEM MEMORY????



C# Programming
03-17-2010, 04:54 AM
Hi everyone!
I have recently created a program when you click a button then a running (scrolling) string is appeared on the TextBox component....this line is "running" from right to left (like in Winamp) ...I used a timer object to alter string by replacing the leftmost character to the end of a string ...so it looked like it was moving ....but I don't understand:
every time i was using this code in Timer.Elapsed handler:

str = str.Substring(1, str.Length - 1) + str.Substring(1, 0);
txtMessage.Text = str;

so everytime the timer fires an event, a new string object is created (cause string are immutable in C#)
but in the System Process window it ate no memory at all!!!!
Does GarbageCollector work so fast?