[racket] Garbage collection in Racket
On Jul 22, 2012, at 4:21 PM, Harry Spier wrote:
> 1) If a data structure is out of scope
The above makes no sense. A data structure exists at run-time. Scope is an attribute of program text.
> and is not closed over by a closure, does that always ensure that doing a (collect-garbage) will reclaim the memory?
Garbage collection may retrieve all memory that can provably not affect the future of a program execution. Existing garbage collectors perceive all of memory as a graph and traverse it, starting from a set of roots (e.g., stack, registers). If they can reach a chunk of memory, the corresponding data stays available; otherwise, it is made available fir future allocations.
> 2) What triggers automatic garbage collection.
Any attempt to allocate memory that does not find enough available memory: cons, struct construction, lambda, etc.
-- Matthias