Garbage Collection (L13) Flashcards
Which type of memory allocation must be explicitly handled by the programmer (or by GC)?
Dynamic.
What is a memory leak?
Failure to reclaim unused, previously dynamically
allocated memory.
What is the most fundamental, two phase garbage collection technique called?
Mark and sweep.
What are tracing collectors?
These are a class of garbage collectors that identify/reclaim unreachable objects by tracing the program’s execution.
What is the root set?
It is the initial set of objects that are directly accessible and serve as the starting point for marking all other reachable objects.
What types of variables make up the root set?
Any global variables, and variables/references on the current call stack.
Describe the mark phase of the mark and sweep algorithm.
Starting from the root set, all accessible objects in memory are looked at and marked as “in use” by setting a flag (if in use).
When are in use flags cleared?
At the start of a GC cycle (prior to mark phase).
Describe the sweep phase of the mark and sweep algorithm.
The GC cycles through all objects in the heap and, if their flags aren’t set, reclaims their memory.
Does GC run continuously?
No, since it steals processing cycles away from the application.
What is the most common strategy for choosing to invoke the garbage collector?
When memory is low.
Can the GC be invoked on a predefined schedule?
Yes.
In practice, when do (naive) mark and sweep algorithms begin to fail?
In large applications.
What is the tri colour approach?
GC in which candidates for reclamation are iteratively moved between three sets until it is certain that they are no longer required.
What is the generational technique?
GC in which the age of objects impacts the frequency of testing - older objects are likely long term and thus considered less.