[Mono-devel-list] Re: AppDomain unloading

Varga Zoltan vargaz at freemail.hu
Mon Oct 20 15:11:54 EDT 2003


                                                     Hi,

Paolo Molaro <lupus at ximian.com> írta:

> 
> We need to force a GC and finalization run before
unloading. At that
> point, all the objects that belong to the domain and need
finalization
> are force-finalized, even if they are still reachable. We
need a sort of
> callback in libgc to get the list of objects. We also
won't allow the
> objects to be marked for finalization again.

 This could work, but it creates problems, since objects
will be finalized
in a random order, meaning an object will be finalized
before the
objects whose finalization depends on this object being alive.

> We could add to libgc a function that walks the list of
objects
> registered for finalization and pass them to a callback:
> in the callback we read the first word (the vtable) and do
a lookup
> in domain->class_vtable_hash to check if it belongs to the
domain (this
> is needed because not all the memory chunks registered for
finalization
> are MonoObjects, otherwise we could use
obj->vtable->domain directly: or
> we could change the monitor code to not require the
finalization of the
> syncblock, this would save memory and it would make for
faster lock
> implementation as well).
> With this change in place, there is no need to go and
actually delete
> the objects belonging to the domain explicitly: they will
die over time,
> since no reference to them would be left. We store some
domain-specific
> objects ourselves in some runtime table: we need to remove
them manually
> from there. Since all the objects are finalized, we can
delete the
> vtables as well (and the code for the methods).
> 
> Hope this helps.
> 
> lupus
> 
> -- 
>
-----------------------------------------------------------------
> lupus at debian.org                                    
debian/rules
> lupus at ximian.com                             Monkeys do it
better
> 
> 
> 







More information about the Mono-devel-list mailing list