Talk:Reference counting
From Wikipedia, the free encyclopedia
Since when has reference counting been called "garbage collection"?
I thought that the taxonomy was:
- Memory management
- Manual
- Automatic
- Garbage collection
- Reference counting
- Region inference
- etc...
[edit] Perl use Reference counting
I think it should be added that Perl also uses Reference Counting with no cycle detection[1]. Programmers should deal with cycles via proxy objects or something similar[2].
[edit] MacOSX Objective-C/Cocoa Reference Counting
Obj-C/cocoa also uses reference counting, however it should be explicitly noted that reference counting in obj-C/cocoa is done manually by the programmer, which means that the overzealous count updates with list traversals don't happen in this language (for other reasons too, such as encapsulation, so for example an NSArray object would handle traversals and counts of items it owns without ever incrementing them. If you pull an object from an array, you increment its count manually to retain that you are now responsible for it, which is necessary anyway).
It should be noted that reference counting can be a form of garbage collection if it is done automatically. If automatic, then it's like a constant cycle of black-grey-white listing that automatically collects 'white' objects once they become unreachable. It should further be noted that by doing manual reference counting, you can avoid the (expensive) need to copy objects that are passed to functions or methods, since the methods increment their reference counts upon accepting them, so even if the previous owner decrements the count the object won't be prematurely dealloced and produce a dangling pointer for the current owner. Done this way, it can actually reduce the cost of manual memory management (by reducing the effective number of allocs required, since you no longer have to alloc copied objects because you don't need to copy them under normal circumstances).

