in Compiler Design edited by
803 views
6 votes
6 votes

Suppose we are working with a programming language that supports automatic garbage collection. This means that:

  1. Uninitialized variables are assigned null values.
  2. Unreferenced dynamically allocated memory is added back to free space.
  3. Unreachable $\text{if – then – else}$ branches are pruned.
  4. Expressions where array indices exceed array bounds are flagged.
in Compiler Design edited by
803 views

1 Answer

10 votes
10 votes
Best answer

Garbage collection  also known as automatic memory management, is the automatic recycling of dynamically allocated memory.
Garbage collection is performed by a garbage collector which recycles memory that it can prove will never be used again.
Systems and languages which use garbage collection can be described as garbage-collected.

As long as address space is available in the memory, the runtime continues to allocate space for new objects.
However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory.
The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made.

So, option B is correct.

Unreferenced dynamically allocated memory is added back to free space.

edited by

Related questions