Alex

Alex

  • NA
  • 4
  • 0

C# .net cf 3.5 IDisposable, disposing objects

Oct 26 2009 6:43 AM
Hi
my problem is with memory leaks..... i would like to know how to use dispose, IDisposable interface...
my current problem is:
have: 1  controller class, 1 from (for simpliticy, also have 1 controller - 3 forms)

so..for example if i click to a menu elment that make the controller (the controller download or just build up what need to be in the screen, when it is finished i open the form) what is the best practice when i close the form to release the controller too ?
maybe i`m a little not so understandable so here is a litte mockup...

Controller:
private DataFrom dataform = null;
//other local variables (hashtables, objects written by me)

//constructor
public Controller()
{
  this.dataform = new DataForm(this);
}

public init()
{
   //building the form
ex: datafrom.listview1.item.add(...) etc....
 dataform.show();
}

Form:
in the form cunstructor i pass the controller

i would like to ask how i can realease the controller and clean up the objects what i used before to build up the form....
till now i used in the form closing method... controller = null;
i bet it is not working cuz after closing the form have much more allocated memory then before.....

anybody can tell me the best practice for free up a memory in this current case ????
thx

Answers (3)