[Gc] Question about weak references
hans.boehm at hp.com
Wed Dec 13 16:36:46 PST 2006
> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com
> [mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Stephane Epardaud
> Sent: Thursday, December 07, 2006 2:42 AM
> To: gc at napali.hpl.hp.com
> Subject: Re: [Gc] Question about weak references
> Some more questions regarding weak references.
> Is there a way to ask the GC if a certain address has been
> allocated by the GC ?
GC_base() != 0 is the easiest way to tell that.
> Do I need to unregister the dissapearing link in the
> finalizer of the object holding the link ?
Not usually. The only issue is if the weak pointer object itself is
> Or is this done by the GC automatically when it collects the link ?
> I'm trying to use this system in Bigloo, and Manuel Serrano
> tells me using finalizers makes the GC noticeably slower. Is
> this still true ?
Yes. That's true for nearly all implementations of Java finalizers as
well. The collector has to keep a collection of all finalizers in an
explicit data structure. Thus you're typically performing twice as much
memory allocation, along with lots of other work. With a generational
collector, things are normally even worse, since finalizable objects are
guaranteed to survive at least one collection. For some disconcerting
numbers, see slide 8 in my 2005 JavaOne talk:
> Does using dissapearing links enable the same code paths than
> the finalizers ?
Mostly, though they don't prolong object lifetimes.
> Thank you for your help.
> Gc mailing list
> Gc at linux.hpl.hp.com
More information about the Gc