Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For real time programming, does reference counting have an advantage over garbage collection in terms of determinism?

If you were designing a programming language that features automatic memory management, would using reference counting allow for determinism guarantees that are not possible with a garbage collector?

Would there be a different answer to this question for functional vs. imperative languages?

like image 372
Steve Avatar asked Jun 26 '10 19:06

Steve


People also ask

Is reference counting better than garbage collection?

Advantages and disadvantages. The main advantage of the reference counting over tracing garbage collection is that objects are reclaimed as soon as they can no longer be referenced, and in an incremental fashion, without long pauses for collection cycles and with clearly defined lifetime of every object.

What is the role of reference counting in garbage collection?

Reference counting. Reference counting garbage collection is where each object has a count of the number of references to it. Garbage is identified by having a reference count of zero. An object's reference count is incremented when a reference to it is created, and decremented when a reference is destroyed.

What is the difference between arc automatic reference counting and GC garbage collection )?

the short and sweet answer is as follow: GC of java is Runtime, while ARC is compile time. GC has reference to the objects at runtime and check for the dependencies of object runtime. While ARC appends the release, retain, autorelease calls at compiletime.

Is garbage collection good in programming?

Garbage collection is great. It removes a lot of cognitive load by handling memory management for you. But there are still some potholes to watch out for. It isn't a panacea for all your resource-management needs and can even have some undesirable side-effects.


1 Answers

would using reference counting allow for determinism guarantees that are not possible with a garbage collector?

I don't see how. The process of lowering the reference count of an object is not time-bounded, as that object may be the single root for an arbitrary large object graph.

The only way to approach the problem of GC for real-time systems is by using either a concurrent collector or an incremental one - and no matter if the system uses reference counting or not; in my opinion your distinction between reference counting and "collection" is not precise anyway, e.g. systems which utilize reference counting might still occasionally perform some memory sweep (for example, to handle cycles).

You might be interested in IBM's Metronome, and I also know Microsoft has done some research in direction of good, real-time memory management.

like image 122
Oak Avatar answered Oct 17 '22 15:10

Oak