What is the use of GC.Collect() and how can i use it efficen
what is the use of GC.Collect() and how can i use it efficiently.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Biswa Pujarini MohapatraRank #465 · 5.4K reputationPosted Feb 24, 2014, 7:12 PM EST
Ranjit PowarRank #553 · 4.4K reputationPosted Feb 24, 2014, 7:14 PM EST
Sanjay Dholakiya82 reputationPosted Feb 26, 2014, 6:05 PM EST
Hi,
GC does automatic memory management and handles object's cleanup allocated on heap memory area.
No one can say when the garbage collection will be called to claim the memory for those objects that are no longer in use.
Therefore, you can use GC.Collect() method to force the framework to start garbage collection task. To call GC.Collection method explicitly is not a very good idea because let allow the framework to do its work in it's own way. You can call, however, to suit some particular requirement.
For more.... http://msdn.microsoft.com/en-us/library/xe0c2357(v=vs.110).aspx
- Sanjay Dholakiya