Why don't they need them, and if someone decided to implement a VM that used them, what problems might they face?
Reference counting is subject to memory leaks due to cyclical references. Imagine you have a simple "node" object which has a reference to another node, and suppose you set its reference to itself. The reference count for that object will always be 1 even if there is no handle to it from a global or stack variable so it will never be garbage collected and is leaked memory. This is a trivial example but any cyclical reference will have the same problem.
Of course, cyclical references can be detected but presumably the overhead of doing so adds enough complexity that other GC methods are more attractive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With