[kaffe] Weak references/Class destruction

Guilhem Lavaux guilhem at kaffe.org
Wed Dec 22 10:39:13 PST 2004


Helmer Krämer wrote:

>Guilhem Lavaux <guilhem at kaffe.org> wrote:
>
>Hi,
> 
>  
>
>>Here is a patch which changes the way the classes are destroyed and 
>>implements
>>weak references for boehm-gc and kaffe-gc. This fixes class concurrent
>>destruction issues which was bugging boehm-gc (and maybe also kaffe-gc) and
>>should insure that we do not access already freed memory.
>>    
>>
>
>If I remember it correctly, the problems with boehm-gc and
>garbage collecting classes are:
>
>a) Suppose class A  is the only class implementing interface I. If
>   A becomes unreachable, so does I. In this case however, there's
>   no guarantee that C is destroyed before I. This means that destroyClass
>   has to deal with the fact that I might already have been destroyed
>   when C is destroyed. This gets complicated for the implementors
>   table and the interface dispatch tables because destroyClass has
>   to remove C from some of the structures stored inside I.
>
>b) Same thing when a class A and its super class A' become unreachable
>   at the same time. In this case, some of the pointers stored in the
>   vtable (and interface dispatch table) may no longer be valid because
>   A' was already destroyed.
>
>The solution for a) is to use weak references.
>
>The solution for b) is to use allocation types that are automatically
>freed by the gc for everything that might be stored in a vtable (or
>interface dispatch table).
>
>Is this correct so far?
>
>  
>
Completely right ! :)

Regards,

Guilhem Lavaux.



More information about the kaffe mailing list