My Hindi Forum

Go Back   My Hindi Forum > Miscellaneous > Tech Talks
Home Rules Facebook Register FAQ Community

Reply
 
Thread Tools Display Modes
Old 16-01-2010, 06:29 PM   #1
DotNet
Member
 
Join Date: Jan 2010
Posts: 58
Rep Power: 15
DotNet is on a distinguished road
Default How to invoke or force run garbage collector in .Net??

First thing first, garbage collector is a piece of code written for .net framework, so that any object which is not destroyed by the developers, can be taken care of. This is done to solve the biggest issue, programmers usually face, the Memory Leak problem.

So, how to get it working. Simple. You don't need to. .Net framework is smart enough to understand when a lot of objects are not being destroyed properly, and run this piece of code automatically. Basically its like a maid which cleans up your room without asking.

But what if you still feel that this smartness of .Net garbage collector is not enough, and you still need to tell it when to do the housekeeping for you. Its very simple. Just one line of code and its done. All that you have to do is, add this line in your code where you feel to force garbage collector to run.

Quote:
System.GC.Collect();
That's it. Nothing else to do. Sometimes I really wonder programming can't be any simpler than this. What do you think?
DotNet is offline   Reply With Quote
Reply

Bookmarks

Tags
.net, destroy object, garbage collector, memory, memory leak


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +5. The time now is 10:25 PM.


Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
MyHindiForum.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.