Memory Leak

G

gc

I am developing a C# application for pocket pc (ipaq 4700) SP3
For all the forms that the app uses, I use showdialog() and then I
close and I dispose them.
For all the classes that I am using I have descructors and I dispose
the SqlCeDataAdapter and the SqlCeCommands
I also call Dispose() for every object that support it.
Unfortunatelly after when I am using the application for about an hour
I am running out of memory.
when the application exits I have back all the memory.

Is something that I'am missing?

Is something that I must add before "base.Dispose( disposing );" on
every "protected override void Dispose( bool disposing )" form method?
 
G

gc

Could you please tell me if I am doing something wrong


Cursor.Current = Cursors.WaitCursor;
frmCustomerCard CustomerCardForm = new frmCustomerCard
(mainForm,this,customerCode,customerBranchCode);

CustomerCardForm.ShowDialog();
CustomerCardForm.Close();
CustomerCardForm.Dispose();
CustomerCardForm = null;


protected override void Dispose( bool disposing )
{
#region Clean up resources
mainForm = null;
parentForm = null;

customerCode = null;
customerBranchCode = null;
#endregion

base.Dispose( disposing );
}

public CustomerHandler(SqlCeConnection sqlCeConnection)
{
//
// TODO: Add constructor logic here
//
da = new SqlCeDataAdapter(defaultSQL, sqlCeConnection);
}

~CustomerHandler()
{
#region clean up
da.SelectCommand.Dispose();
da.SelectCommand = null;

da.Dispose();
da = null;

defaultSQL = null;
#endregion
}
 
S

Sergey Bogdanov

Seems everything is ok, except one thing - code from ~CustomerHandler
would be better to place into Dispose method to determine finalization
process. I do not see the whole code, if CustomHandler is a singleton
object then you can leave it as is.
 
G

gc

thank you Sergey for your response,

unfortunatelly the problem was that Form Dispose does not dispose Form
controls !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top