GC: does Observable.addObserver() create a weak or strong reference?

Discussion in 'Java' started by Josef Garvi, May 27, 2004.

  1. Josef Garvi

    Josef Garvi Guest

    When I add an Observer to an Observable, will that produce a weak or a
    strong reference? By weak, I mean a reference of the type WeakReference,
    like in WeakHashMap that will not keep the GC from collecting my Observer.

    --
    Josef Garvi

    "Reversing desertification through drought tolerant trees"
    http://www.eden-foundation.org/

    new income - better environment - more food - less poverty
     
    Josef Garvi, May 27, 2004
    #1
    1. Advertisements

  2. Josef Garvi

    Josef Garvi Guest

    Josef Garvi wrote:
    > When I add an Observer to an Observable, will that produce a weak or a
    > strong reference? By weak, I mean a reference of the type WeakReference,
    > like in WeakHashMap that will not keep the GC from collecting my Observer.


    The answer is no, as the Observable stores its Observers in a Vector, which
    is strong references.

    --
    Josef Garvi

    "Reversing desertification through drought tolerant trees"
    http://www.eden-foundation.org/

    new income - better environment - more food - less poverty
     
    Josef Garvi, May 27, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kuan Zhou
    Replies:
    1
    Views:
    6,546
    Paul Uiterlinden
    Jan 24, 2005
  2. Gabriel Zachmann

    strong/weak typing and pointers

    Gabriel Zachmann, Oct 28, 2004, in forum: Python
    Replies:
    102
    Views:
    2,313
    Carl Banks
    Nov 13, 2004
  3. j_mckitrick
    Replies:
    2
    Views:
    694
    Cameron Laird
    Nov 13, 2004
  4. John Nagle
    Replies:
    3
    Views:
    447
    John Nagle
    Feb 25, 2007
  5. Jason Cavett
    Replies:
    1
    Views:
    640
    Tom Hawtin
    Apr 19, 2007
  6. Strong/weak typing

    , Aug 1, 2008, in forum: Python
    Replies:
    13
    Views:
    760
  7. namekuseijin

    Re: "Strong typing vs. strong testing"

    namekuseijin, Sep 27, 2010, in forum: C Programming
    Replies:
    214
    Views:
    4,497
    Nick Keighley
    Oct 17, 2010
  8. Navindra Umanee

    strong ref from weak ref?

    Navindra Umanee, Feb 12, 2005, in forum: Ruby
    Replies:
    2
    Views:
    296
    Navindra Umanee
    Feb 12, 2005
Loading...