In this mode, you allocate the garbage collector on the heap, & give it to Giggle by calling setGc on it. After that, Giggle owns the Garbage Collector & will tell it when to shutdown. Giggle will also delete it.
So your program looks like this:
using CyberTiggyr::giggle::DefaultCollectorType; using CyberTiggyr::giggle::gc; using CyberTiggyr::giggle::setGc; int main (int argc, char *argv[]) { setGc (new DefaultCollectorType); run_my_app (); return 0; }
Some rules include:
A disadvantage of this system is that it reduces your options of where to allocate your Garbage Collector. You must allocate it on the heap, but with just that one disadvantage, you get a lot of benefits from simplification. You just create your Garbage Collector with new, hand it to setGc, & forget about it. Giggle takes care of everything else.
A disadvantage is portability. During program shutdown, Giggle would shutdown & then delete the Garbage Collector. Is that portable? Is it possible that, on some systems, the heap memory manager would have shutdown by the time Giggle figured out the program was exiting?