In Microsoft .NET, which component actually reclaims memory for objects that no longer have live references on the managed heap?

Difficulty: Easy

Correct Answer: Garbage Collector

Explanation:


Introduction / Context:
The managed runtime in .NET automatically frees memory for objects that are no longer needed. This automatic memory management is a core productivity and safety feature that reduces bugs like dangling pointers and double frees. The question asks you to identify the specific component responsible for reclaiming memory on the managed heap.


Given Data / Assumptions:

  • The environment is Microsoft .NET with a managed heap.
  • Several runtime terms exist: CLR (Common Language Runtime), CTS (Common Type System), class loader, and the garbage collector.
  • We want the component that actively frees memory of unreachable objects.


Concept / Approach:
Within the CLR, the Garbage Collector (GC) is the subsystem that tracks object reachability, compacts memory (when applicable), and reclaims space used by objects that are no longer referenced by any live roots (such as stack variables, static fields, or CPU registers). Other components like the CTS and class loader provide type rules and load types, but do not reclaim memory.


Step-by-Step Solution:
Identify the memory-reclamation task → this is the GC’s role inside the CLR.Distinguish from CLR umbrella → CLR is the host environment; GC is the specific part that frees memory.Confirm that class loaders only load types/assemblies and CTS defines types; neither frees memory.Therefore, the correct choice is “Garbage Collector”.


Verification / Alternative check:
Runtime documentation outlines GC responsibilities: marking unreachable objects, sweeping and compacting generations, and returning memory for reuse by new allocations.



Why Other Options Are Wrong:
Common Language Infrastructure / CLR: umbrella concepts; not the specific reclamation engine.Class Loader: loads metadata and code; no reclamation.CTS: type system rules, not memory management.


Common Pitfalls:
Assuming “CLR” and “GC” are interchangeable; GC is a subsystem of the CLR with a focused purpose: automated heap management.



Final Answer:
Garbage Collector

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion