Use of Garbage Collector in Dotnet?

Garbage Collector:-

  • This is one of the components of CLR (Common Language Runtime).
  • This component is dedicated for de-allocating the un-used memory of the application, automatically.
  • This uses Mark and Compact algorithm for clearing the un-used memory.
  • Mark: Markup the un-used objects and push those objects towards up.
  • Compact: Clear the marked objects memory.

Note: The above functionality is in-built in Garbage collector component. Anyhow, there is a provision for the programmer to command the garbage collector to perform garbage collection at run time, programmatically. Then use the following method from System.GC class.

Syntax: System.GC.Collect();

No comments:

Post a Comment