March 2019
Intermediate to advanced
336 pages
9h 9m
English
The generational collection algorithm divides the heap of objects into generations. A generation of objects will be expired and collected by the algorithm based on their age. The algorithm promotes objects to older generations based on the age of the object in the garbage collection cycle.
The entire heap needs to be scavenged, even if a generation is collected. Let's say generation 3 is collected; in this case, generations 0-2 are also scavenged. The generational collection algorithm is presented in the following code snippet:
func GenerationCollect(){ var currentGeneration int currentGeneration = 3 var objects *[]object objects = GetObjectsFromOldGeneration(3) var object *object for _, object = range ...Read now
Unlock full access