I know this is a strange question, but really I’m very excited to know the answer.
How do you destroy Objects in .Net, and give memory back to the heap?
I know this is a strange question, but really I’m very excited to know
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short Answer
is suppose to force the garbage collection to run but I’ve heard that its more of a polite asking function that may not actually have it run.
Long Answer
I believe C# uses garbage collection, so at best you can ask it to clean up but it really does it on its own time. An object is considered destroyed when there are no references to it.
For example:
Here’s a great article on the garbage collection .NET uses