Interview Question: Why Garbage Collection required?

question-interview @Image courtesy of ddpavumba /

Interview Question: Why Garbage Collection required?

Welcome to CodeSpread!

What is garbage collection?

In two words

“Memory Management”.

In two lines

“Managing the lifetime of object starting from creation, allocation and release it back to free memory pool.”

Why it is required?

We have two scenarios here,

Case 1: Where resources are not released.

Scenario: Resources will keep on getting consumed and will result in memory leak.

Case 2: Where resources are released irrespective of still being used in the code.

Scenario: May result in null pointers exceptions, corrupted memory areas or loss of data.

Garbage Collector manages the lifetime of all objects and avoids any early-release or late-release of resources.

Author: swatiS

Share This Post On


  1. nice superb explaination

    Post a Reply
  2. thanks for the tutorial
    I am having a problem.
    The feature “Create SQL server database” isn’t available , I can’t select it.
    Can you help, please ?

    Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

More from CodeSpread:

  • Interview : a question mark?Interview : a question mark?I like going for interviews for two simple reasons: I found that this is the simplest way to remain updated with the latest knowledge. If we look at the IT trend, daily new software are gett...
  • 20 Dec: Must Read Codes [6-10]20 Dec: Must Read Codes [6-10]We are sharing few must read codes/concepts which are required now and then. Each of these codereads doesn’t require a full length descriptive article so combining them into groups of five. CodeRe...
  • My first experience with LISTS in C#My first experience with LISTS in C#Hi guys, this is Sathish, Lets discuss the concepts of lists. These are the concepts which I have planned to discuss with you guys today. What is a List and how it is advantageous than array...
  • C#: Singleton Design PatternC#: Singleton Design PatternWe know the existence of a design pattern is dependent on a recurring problem. Once the problem is identified, then a well established solution is proposed theoretically and different implementatio...
  • Nice reference for C# evolutionNice reference for C# evolutionWhile going through some posts on MSDN, I came across this beautiful image which can be termed as a one stop solution for C# evolution. This is a gift reference, I would like to share with my frien...
  • Styles of Source Code Comments in C#, SQL, XML, HTML, CSS, JavaScriptStyles of Source Code Comments in C#, SQL, XML, HTML, CSS, JavaScriptDevelopers take months to write beautiful pieces of code and reviewer gets only few hours or I say, minutes to provide suggestions and improvisations. Then it becomes a hard deal for a developer to...
  • How to view Intermediate Code in C# using Ildasm.ExeHow to view Intermediate Code in C# using Ildasm.ExeHi guys, this is Sathish again, today let’s discuss how to view the intermediate code in c#. We know that CLR (Common Language Runtime) is used to convert the MSIL (Microsoft Intermediate Language...
  • Tip : Code Structure C#Tip : Code Structure C#As a developer, I always stress on developing a habit of following the best practices to structure the code. It helps me to easily navigate through the code and also saves a lot of effort in search...