As I understand weak references (and that's not very well), then if the ONLY
reference(s) to an object is/are WeakReference(s), then that object becomes
more and more likely to be collected as memory space grows less. "Real Garbage"
is collected first where possible, and if memory is still tight, then
objects with
only weak refs pointing to them are axed. All this doesn't matter at all
for objects
that are actually directly connected as children inside your scene graph.
If any
non-weak reference connects to your object, then the JVM will die of memory
exhaustion rather than letting it be collected.

What does this mean in practice? It means you can use WeakReferences to
hold lists of objects currently not in use but expensive to build up. As
long as
memory is available, your objects will be available, hanging off these
weaklings,
so you can recycle them rather than building them afresh. If you run very short
on memory, these list pointers suddenly end up pointing to nothing, and if you
need those objects again you will have to re-build them after all. THIS is
basically
what WeakReferences are there for: Storage for objects that's available as long
as memory is plentiful, but the objects are considered expendable (and/or
replaceable) if memory grows scarce.

Hth,

-Carl-

At 10:45 26.07.00 -0400, you wrote:
>Hi all,
>         As I was perusing through the JDK 1.2.2 documentation I notice an
>Object called a WeakReference in java.lanf.ref package.  If Objects from the
>scenegraph were explicitly(programatically) setup with WeakReferences
>immediately prior to programmatic calls to garbage collection could this
>possibly remove such Objects from memory?  I'm not sure I fully understand
>WeakReference but maybe someone with more knowledge could look into it and
>explain it better or maybe why it would or wouldn't work.  Mostly food for
>thought.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to