PC Review

Thread Tools Rate Thread

GC, Should I care?

Chris Mayers
Posts: n/a
      15th Apr 2005

I am trying to track a suspected memory leak in an application I'm writing
and through repeated simplification of my project, I have found the
following which is quite easily replicated should you be prepared to give me
5 minutes of your time...

Create a new C# (Probably the same in VB dotNET but I've not tried it)
Windows application with 2 forms, the default form -Form1 and one other one.
that has a bunch of controls on it (say 20 buttons, 20 labels and a
DataGrid) - Form2.

On the default form, add a button to display the second form with some code

private void button1_Click(object sender, System.EventArgs e)
using (form2 formTwo = new form2())

also on Form1 add a label, and a timer that updates the label text as
follows (updates every 5 seconds -Interval = 5000-):

private void timer1_Tick(object sender, System.EventArgs e)
label1.Text = GC.GetTotalMemory(False);

and finally a button that forces a Garbage Collection:

private button2_Click(object sender, System.EventArgs e)

OK, my question/query is this, if I repeatedly click the button to open the
second form, then close the second form, click the button, close the form
etc. about 20-30 times, the display of GetTotalMemory seems to keep going
up, and even after forcing Garbage Collections, never seems to get fully
reclaimed. Should I care? and if I should, what (if anything) can I do about

I would really appreciate an answer from someone who understands these

Thanks a lot,


Reply With Quote

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook should automatically ask whether a sent item should be sa. =?Utf-8?B?Q29ybmVsaXVz?= Microsoft Outlook Discussion 0 23rd Nov 2004 03:05 PM
Should I or should I not to... GEORGE TAKEV Windows XP Help 2 1st Oct 2004 09:14 PM
Search in outlook should be improved: should work with strings wi. =?Utf-8?B?SmF2aWVy?= Microsoft Outlook Discussion 0 22nd Sep 2004 11:25 AM
Search in outlook should be improved: should work with strings wi. =?Utf-8?B?SmF2aWVyLg==?= Microsoft Outlook Discussion 0 22nd Sep 2004 11:25 AM
sp2... should I or should I not ??? =?Utf-8?B?RnJhbmt0ZWU=?= Windows XP General 8 29th Aug 2004 04:06 PM




All times are GMT +1. The time now is 01:26 AM.