mercredi 11 mars 2015

Freeing or clearing created objects

I have 2 windows forms; Form1.cs and Form2.cs.


Here are the code for Form1.cs in which will show the Form2.cs and Hide the the current Form1.cs



private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
this.Hide();
}


Here are the code for Form2.cs in which will show the Form1.cs and Hide the the current Form2.cs



private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.Show();
this.Hide();
}


I have monitored the memory usage of the application and I have noticed that the memory usage of the application is increasing every time I execute the code above.


Aucun commentaire:

Enregistrer un commentaire