Support a "stable heap" which doesn't get garbage collected
Simon Marlow was explaining the concept on IRC. The problem we're trying to solve is you might have some very long-lived pointer data-structures, and you don't want to waste time traversing this structure on a major GC when you know that it is still going to be alive. Here's the basic idea:
- We have a new generation on the heap called the 'stable heap' (along-side the nursery, gen0, gen1, etc). By default, no objects are automatically promoted from the old gen to the stable heap.
- A user can request an object be moved to the stable heap, creating a stable pointer which points to the object.
- During garbage collection, all blocks in the stable heap are always considered reachable. We don't include the stable pointers in the root set (so we don't trace the stable heap), however, write barriers are processed as usual, and we promote any objects pointed to by the stable heap to the stable heap.
- Users manually request the stable heap to be garbage-collected, usually after deallocating stable pointers.
In short, the stable heap is just another generation, but one which (1) is only collected by user request, and (2) never receives objects from automatic promotion.
This project fits in very nicely with the existing GC infrastructure, so if you understand how everything is laid out this should be reasonably easy to implement. Could be a good ticket for someone who wants to get their hands dirty with the GC.