Instantiating a class in .NET

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

I have a class in .Net which I instantiate in my code
behind on one of my aspx pages.

When I am finished with the instance, what is teh best
method of taking it out of memory. Should I set it to
nothing or can I dispose of it?

Thanks,
Carl.
 
Carl said:
I have a class in .Net which I instantiate in my code
behind on one of my aspx pages.

When I am finished with the instance, what is teh best
method of taking it out of memory. Should I set it to
nothing or can I dispose of it?

Just make sure there are no live references to the object, and it'll be
garbage collected in time. If there are unmanaged resources (file
handles etc) directly or indirectly "inside" the object, you should
probably dispose of those explicitly.
 
Back
Top