I definitely think we should try to get rid of reference counting in
favor of garbage collection. There are a few things that I'm worried
about and that needs investigation.

How complicated is embedding going to be? I suspect it's going to be
more complicated than now in some ways, since interacting with a GC
engine is probably trickier than simply calling AddRef. At the same
time, environments that use GC, such as java, should have an easier time
avoiding leaks.

How is performance going to be during GC? While we're not writing a
real-time app, we don't want the UI to lock up for seconds while GC is
running. If we get better at detecting inactivity from the user, we
might get away with more here since we can run GC while the user is busy
simply looking at a webpage.

Related to the above, should we attempt to use incremental GC. From what
I understand this should be entierly possible with MMgc. However it 
requires that all pointers use special smart-pointers. Including 
pointers that are currently raw-pointers. This seems a little bit scary 
and easy to forget, but might be very nice for performance.

/ Jonas

Jason Orendorff wrote:
> 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

Reply via email to