11 years ago |
11 years ago |
Reference counting is not a bad idea until you have to deal with cycles. Once you need to use cycle of references you have to be extremely careful to break it or the code will leak memory. And sometimes, with complex code, the cycles are not obvious. There are some methods to deal with cycles, but all of them are painful. http://en.wikipedia.org/wiki/Garbage_collection_(computer_sc...
It's just that refcount has its serious drawbacks, for example inability to reclaim the memory in the case of cyclic data structures.