Opportunistic garbage collection

Opportunistic garbage collection is a non-incremental generation-based garbage collection system. It attempts to minimize the probability of disruptive pauses by careful scheduling of scavenges. Scavenge pauses are hidden in pauses created by the running program or by the user; they are also shortened by scheduling them at low points in the stack height, where live data tend to be at a minimum. These heuristics can be surprisingly simple and cheap to implement --- user input primitives provide an effective hook from which to invoke the scheduling routine, since they tend to correspond both to local stack minima and to computational pause boundaries.An additional mechanism is proposed to detect times when it is safe to scavenge an intermediate generation, based on the amount of data surviving from a new-generation scavenge. This mechanism can be used reliably in certain cases, or heuristically in a larger class of cases.