Possible Duplicate:
difference between destructor and garbage collector
Recently i asked this question, now as per the answers I came to the conclusion, that
Ok, let me check whether I got the concept, GC is used to just check whether any disposing of the object is required, and if any it will call the destructor, GC cannot destroy anything on its own, and Destructor on the other hand, will destroy the object at the end of the class, and destructor cannot check for the memory issues, it just destroys everything at the end. am I right?
I commented there, but didn’t got the reply, so I tried to post new question here. can anyone reply, is my conclusion right
No, the destructor (~myClass) just does the stuff you want him to do when an object is no longer needed, like freeing resources (files, connections, …).
Its the opposite of the constructor (myClass), where you set up your object (getting connections, etc).
The GC removes all pointers to the myClass-object when it goes out of scope or the destructor was called (I think). So the location where your object was before in memory can be allocated again.