Garbage collection

With a real computer, we will eventually run out of free space. Garbage collection is one strategy to remove useless information stored in memory during program execution and recycle those memory locations for further use. The basic idea is that in a register machine, only the objects that are reachable from the pointers stored in the registers can influence future computation. All memory locations that cannot be reached are garbage, and may be recycled.

Stop-and-copy

One possible method for garbage collection. The basic idea is to split memory into two halves, "working memory" and "free memory". When working memory fills up, move the useful data from working into free memory (in continuous locations) and then flip the roles of the two halves.
Screenshot 2025-04-06 at 23.45.07.png


Links

Sources