This may be usefull for you. and also check the threads in this forum and beginner forum and SCJP forum.
The Best way to predict your future is to create it
Ankur Sharma
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
posted
0
You very rarely need to call gc(). It is not guaranteed to do anything. The JVM will usually work out when to do gc anyway.
To track the garbage collection of objects, you can use WeakReference objects. You may dedicate a thread to retrieving references from the queue associated with the WeakReferences and processing them accordingly. You may find it useful to subclass WeakReference, to store some additional information associated with the post-GC operation; if you do, be careful not to accidentally hard-reference the original object, or you will prevent it ever being GCd.
Sometimes, you may find SoftReference, or maybe even PhantomReference, more appropriate than WeakReference. The article cited by an earlier poster is a good thing to read, to guide your choice.
Check out also WeakHashMap. I find that useful occasionally.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
Simon Baker
Ranch Hand
Joined: Sep 09, 2004
Posts: 57
posted
0
Also be aware of generational garbage collection, and the fact that the JVM implementation detail in this area changes from release to release. This is probably due to the importance in terms of performance.