1.

What is a Garbage Collector (GC)?

Answer»

When an object is created in C#, CLR (normal language runtime) assigns memory for that object from the heap. This procedure is repeated for every newly created variable/object, however, there is a drawback to everything, Memory isn't unrestricted and we have to CLEAN some utilized space so as to prepare for new items. Here, comes the garbage collection is a picture. Garbage COLLECTOR manages distribution & recovering of memory. GC makes an outing to the heap and gathers all objects that are no longer utilized by the application and free up the memory.

The Garbage Collection is a significant technique in the .Net framework to free the UNUSED managed code data in the memory. In the Common Language Runtime (CLR), the Garbage Collector acts as an automatic memory manager. It gives the following advantages:

  • Empowers you to build up your application without LIBERATING memory.
  • Assigns objects to the managed heap efficiently.
  • Recovers objects that are never again being utilized, clears their memory and keeps the memory accessible for future allotments.
  • Gives memory security by ensuring that an object can't UTILIZE the content of another object.


Discussion

No Comment Found