[Neko] Reference counting

Matt Campbell mattcampbell at pobox.com
Tue Aug 21 04:16:25 CEST 2007


What challenges would be involved in modifying Neko to use reference 
counting instead of or in addition to GC?  Could it be done without 
modifying the C FFI?  I suppose that the use of setjmp/longjmp for error 
handling would pose a significant challenge, though if reference 
counting is used in conjunction with GC, then a possible compromise 
would be to let GC reclaim no-longer-used resources when an error occurs.

I am aware that the merits of reference counting versus GC have been 
debated for years (decades?), and GC seems to have prevailed.  I amalso 
aware that the classic problem with reference counting is inability to 
detect reference cycles.  However, reference counting has the advantage 
(undisputed, AFAIK) that in the normal case, resources are reclaimed as 
soon as they're no longer used.  I don't care much about memory here; 
I'm more concerned about open files, COM objects (I know there is no COM 
library for Neko yet), and the like.  So my preference would be a VM 
that does both reference counting and GC, as the C implementation of 
Python does.

Thoughts?

Matt



More information about the Neko mailing list