My Hindi Forum

My Hindi Forum (http://myhindiforum.com/index.php)
-   Tech Talks (http://myhindiforum.com/forumdisplay.php?f=20)
-   -   How to invoke or force run garbage collector in .Net?? (http://myhindiforum.com/showthread.php?t=202)

DotNet 16-01-2010 06:29 PM

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?


All times are GMT +5. The time now is 05:47 AM.

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.