News for hackers. Stuff that matters.
Re:Ask HN: Why do langs with alleged “automatic memory manag... by Someone on Saturday July 20, 2019 @01:27PM (#20487092)
Ones that are either not reasonably performant, don’t free resources as soon as they become unreachable, or are too restricting.

The fix you refer to is one, but it falls under ‘not reasonably performant’.

One could also make it illegal to have cycles (easy way to do that: make it illegal to update any references). For many, many, that will fall under ‘too restricting’, though.

Alternatively, allow updates to references, but give every allocated object a ‘bit’ that indicates whether, from it, a reference can be reached that contains such an updated reference that points to an object created later (maintaining that property is doable, but may not be ‘reasonably performant’)

You can use that later: when the reference count of an object goes to zero, and the object has a reference to an object O with that bit set, check whether the graph reachable from O can be reached from elsewhere. Again, that’s doable, but likely not performant.

It somewhat depends on how common circular references are in real world code, though. I’m not aware of any papers researching that.

There are no comments on this comment yet.