Memory Leakage

  • Thread starter Erdem ALKILIÇGIL
  • Start date
E

Erdem ALKILIÇGIL

Hello all,
i have a memory leakage problem..
Program has two forms. one of the form(mainform) the other one is
(contentform). when user clicks on the mainform contentform is opened and
shows an htmlpage..
contentform has a button to close it.

I am using Opennetcf.org's htmlviewer..

I am disposing the form by contentform.Close()
also using

{
viewer.Clear();

if (disposing)

foreach(Control c in Controls)

c.Dispose();

GC.Collect();

base.Dispose(disposing);

}

protected override void OnClosed(EventArgs e)

{

Dispose();

base.OnClosed(e);

}

Where am i doing wrong?
 
R

Rick Winscot

Erdem,

In your main form create an instance of your content form: static frmContent
c = null;

When you want to display the form... call c.Show(); In your content form -
on closing... e.canel = true; and this.Hide() instead....

THEN - when you close your app... make sure to call c.Dispose(); to make
sure that the form instance gets cleaned up.

If you need to pass data or anything to the form... you can create a public
function to pass data to instead of having to use a constructor.

If you need *many forms... that is fine - but use traditional C++ typcial
counter methods to make sure you can keep track of your objects (like you
indicated). If you only really need one form... the above method will be
more than sufficient.

Be careful trying to force a gen0 collection - as it may cause additional
memory problems... especially when your managed code is tied to unmanaged
resources.

Cheers,

Rick Winscot
www.zyche.com
 
E

Erdem ALKILIÇGIL

I have sevent different forms in real application..
and the usage of forms are like this
mainform->first->second->third->forth->second etc.
How can i show the forms with this construction?
 

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