By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

Releasing Resources

P: 1
Hi All,
Thank you in advance. I am having trouble releasing resources when I open a child form. Please see the code below.
Expand|Select|Wrap|Line Numbers
  1. Form f;
  2. private void button1_Click(object sender, EventArgs e)
  3. {
  4.     f = new Form2();
  5.     f.FormClosed += new FormClosedEventHandler(childForm_FormClosed);
  6.     f.Show();
  7. }
  9. private void childForm_FormClosed(object sender, FormClosedEventArgs e)
  10. {
  11.     f.Dispose();
  12.     f = null;
  13. }
When I use ANTS profiler, it appears references to form2 are still active after I close form2. The live object count goes down but not as much as I would expect. The type of objects that are "living" are things like decimal, string, size, color, ..... Even if I force a GC they are "live".

Am I missing something here.

Thanks again.
Jan 2 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.