AddRef and Release constitute a contract between every XPCOM object
and all its users. The contract governs object lifetimes,
finalization order, and memory management.
Advantages of this specific contract:
1. It's relatively simple.
2. It requires no global coordination.
3. Prompt destruction. If there are no cycles, objects are
destroyed as soon as they're no longer needed.
4. It destroys objects in the right order.
Disadvantages:
1. It requires manual bookkeeping throughout the codebase
(nsCOMPtr, NS_ADDREF, NS_RELEASE, already_AddRefed,
kungFuDeathGrip, etc.) This clutters up the code, and all the
virtual method calls and AtomicIncrements can't be good.
2. The problem of reference cycles is built in.
3. Interacting with other memory management schemes is painful
and slow. (See cycle collector, XPConnect.)
In Mozilla 2, we should change this to require less effort from the
programmer and less clutter throughout the code. This means coming
up with a new contract that cooperates with garbage collection,
rather than fighting it.
More on this in a few hours.
-j
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom