Application uses too much memory


I'm working on a Pocket PC application in VS 2003 (C#).
I'm working with a database(collecting, inserting data). The application has several screens.
While testing I noticed that the application constantly uses more and more memory while I navigate from one screen to another several times.
I used some threads. I thought that mismanaged threads are the problem and removed them for testing. Even without using threads the used memory increases.
Even if I quit the application the used memory is not freed(?!!!!).
Could someone give me some hints of where the problem might be?

I tested a little more and I found new questions.
A) Should I override the dispose method for the screen objects(all the objects ) I use?
Because at the moment I don't do so.
B) Is there a problem with the next approach(I'll give some test code sample)

The main form contains a control and the control has a button. When the button of the control is clicked, in the handler, a method of a singleton class it is called wich removes the current control object, instantiates a new one and adds the new one to the main form.
Is there a problem for the current control to be removed indirectly(through the singleton method)from the main form, in the handler for its own button.
//method from the singleton class.....

public void RemoveAndAdd()
{
mainForm.Controls.Remove(mainForm.myControl);
mainForm.myControl = new ClassControl();
mainForm.Controls.Add(mainForm.myControl);
}
//........

//the class of the control wich is added to the mainForm
public class ClassControl : Control
{
private Button _btn = new Button();

//private Bitmap someImage;
public ClassControl()
{
_btn.Bounds = new System.Drawing.Rectangle(20,20,100,100);
_btn.Click +=new EventHandler(_btn_Click);

this.Controls.Add(_btn);
}
private void _btn_Click(object sender, EventArgs e)
{
Singleton.Instance.RemoveAndAdd();
}
}
Singleton class knows about the main form like this : "Singleton.Instance.MainForm = this;"
C) My PocketPC has a memory visualizer. I run some tests and I noticed something.
It shows me 30MB free program memory after reset. I run a program or two and I noticed that even if I exit the application it doesn't bother to clean up all the memory the application used. Looks like 15MB free memory is enough for him. It cleans till gets 15MB ree memory and stops. Why?....
Well, I found be very, very pleased if someone would help me with some answers...
Thank you

[2629 byte] By [AndrewKowalsky] at [2008-1-28]
# 1
When RemoveAndAdd() is called, you are are creating a new control, however the previous control is not being disposed of, for example, you should do something like this:

public void RemoveAndAdd()
{
mainForm.myControl.Dispose(); // This will remove the control from the Form
mainForm.myControl = new ClassControl();
mainForm.Controls.Add(mainForm.myControl);
}

I'm not exactly sure what you are trying to achieve here, why do you need to recreate the control each time the button is clicked?

DavidM.Kean at 2007-9-8 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 2

I apologize for answering too late to the message. I solved the problem long ago by using Dispose all over the place instead of letting GC handle the cleaning..
The problem was I was allocating a lot of memory by changing screens in my application.
AndrewKowalsky at 2007-9-8 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...