I've been trying to think of a solution to use over here at Remedy for making the garbage collector reference count allocations instead of the current scan method (even with Rainer Schütze's GC it still does a scan, and I'd feel much more comfortable not having to schedule a GC collection somewhere in our update loop).

I've totally missed the other threads on reference counting, but should reference counting be a part of some library that you can optionally use or should the garbage collector hide all that from you?

My thinking on the subject is that you only need one additional function added to the garbage collector that handles pointer assignments. The parameters are a ref to the pointer you're assigning to, and the new pointer. The GC would then decrement the reference count for the memory referenced by the pointer you're assigning to, and increment the reference count fr the new memory referenced.

This, I imagine, would fit neatly in with slices and classes equally. It would also be optional - the current default GC wouldn't do anything with the function and . The downside is that a pointer assign would invoke a GC call and that it would still need to deal with circular dependencies in some fashion (however dealing with that at an allocation level rather than a class level seems potentially less problematic to me).

If this is beyond the scope of this thread, I'll start up a new one to discuss all the potential pitfalls and problems that could be encountered. I haven't had any time to actually do research in to it or trial it yet.

Reply via email to