How common are circular references? Would reference-counting GC work just fine?

Posted by user9521 on Programmers See other posts from Programmers or by user9521
Published on 2010-12-28T15:13:42Z Indexed on 2010/12/28 15:59 UTC
Read the original article Hit count: 239

How common are circular references? The less common they are, the fewer hard cases you have if you are writing in a language with only reference counting-GC. Are there any cases where it wouldn't work well to make one of the references a "weak" reference so that reference counting still works?

It seems like you should be able to have a language only use reference counting and weak references and have things work just fine most of the time, with the goal of efficiency. You could also have tools to help you detect memory leaks caused by circular references. Thoughts, anyone?

It seems that Python uses references counting (I don't know if it uses a tracing collector occasionally or not for sure) and I know that Vala uses reference counting with weak references; I know that it's been done before, but how well would it work?

© Programmers or respective owner

Related posts about language-design

Related posts about garbage-collection