Hi,
Iam working on an application where objects are more often have to be dynamically created!!!
How can i dispose the following objects completely from memory?
a form object
class object
dataset object
strings etc
By assigning null only its reference is lost and not the object?
Can anyone tell me the correct way of disposing these objects?
Also is it proper to use Dispose method for all objects?
Hoping for a better answer!!!
Thanks
Disposing objects
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mahesh ChandRank #1 · 393.4K pointsPosted May 29, 2006, 6:12 AM EDT
Using Dispose is not recommended unless you have some resources such as GDI+ that must be disposed.
Darren Marshall17 pointsPosted May 29, 2006, 9:09 PM EDT
As previously mentioned the Garbage Collection of the CLR does a good job for you.
Edit: By assigning null, the Object is no longer referenced and then the Garbage Collection eats up the Object and will free the memory. Cant hurt to assign null to Objects you no longer require.