Patch: finalize interned strings

Bryce McKinlay bryce@albatross.co.nz
Wed Apr 12 15:25:00 GMT 2000


Tom Tromey wrote:

> >> I'm now wondering: Does the collector guarentee that finalizers
> >> will be run immediatly when an object is collected? Or can the
> >> running of finializers be deferred until a later collection in some
> >> cases?
>
> Jeff> Finalizers should run *before* an object is collected.
>
> Yeah.  I interpreted Bryce's question as "will the finalizer be run
> immediately when the object is unreachable?".  And the answer is "not
> necessarily".

Right, but as long as the finalizer is run at some stage *before* the
object gets collected, there shouldn't be a problem, so I think what
we're trying to do with the finalizer is correct. The pointers in the
hashtable are already basically weak references, as the hashtable is
allocated as pointer-free memory so it shouldn't be scanned during
marking.

I think I may have found the problem though (and now I understand what
DELETED_STRING is trying to do): if you have two strings that hash to the
same value, _Jv_StringFindSlot will return the wrong index in the case
that the first string with the same hash value has already been
finalized. Hmm...

regards

  [ bryce ]




More information about the Java-patches mailing list