The Artima Developer Community
Sponsored Link

Legacy Design Forum
Finalization and Cleanup

Advertisement

Advertisement

This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Weakrefs

Posted by Thomas on December 07, 2001 at 9:25 AM


You don't actually force gc when invoking System.gc() you merely advise the RunTime to run the gc.

Please also note that the WeakReference is not only nullyfied when running on low memory, but also if the object is left with only that (weak) reference as a holder for a long time.

> > Correct me if I am wrong, but won't the WeakReferenced
> > objects be reclaimed by GC only if it is running low
> > on memory and do not have any other strong references?.
> > You might want to start your command line program with

> > java -Xmx1M <- restrict your VM to 1 MB memory.

> No.
> You can force GC by invoking the static method gc() on the
> System object. eg:
>
> System.gc();
>
> This makes it easy to test wrefs.






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us