Date.Now causing increasing memory usage?

Hoogie

Member
Joined
Jan 22, 2014
Messages
12
Programming Experience
1-3
I'm curious, why would a timer checking the exact date/time every second cause an increase in memory according to task manager every time it ticks?

VB.NET:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        Label1.Text = Date.Now


    End Sub

That increases memory usage by about 6-8kb per tick (second). I'm developing a program that is checking the current system time to other times and I have it changing every second. Normally if this program wasn't run for very long that small amount would be minor, however I am developing it to stay open/active on a reporting server to run reports at a specific time. Is there a way to do this without the memory increase? Thanks for help in advance.
 
You're creating a new String object each tick. Don't worry about it, the previous string objects are garbage collected every now and then. .Net is a managed platform, and that includes Automatic Memory Management

Also, turn on Option Strict and change the code to Date.Now.ToString - data type awareness is a better start in programming.
 
Back
Top