import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.lang.ref.SoftReference;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;

/**
 * Soft ref for implementing cache
 */
public class GCTest {

	public static void main(String[] args) {
		Runtime runtime = Runtime.getRuntime();

		ReferenceQueue<GCObj> queue = new ReferenceQueue<GCObj>();

		for (long j = 0; j < 50000000; j++) {
			System.out.println("Free=" + runtime.freeMemory());
			GCObj obj = new GCObj("weak");
			WeakReference<GCObj> ref = new WeakReference<GCObj>(obj);
			SoftReference<GCObj> ref2 = new SoftReference<GCObj>(new GCObj("soft"));
			PhantomReference<GCObj> ref3 = new PhantomReference<GCObj>(new GCObj("phantom"), queue);
			System.gc();
		//	Reference freeObj = queue.poll();
		}
	}
}

@@ -185,39 +185,570 @@
 %0A * 
-Soft ref for implementing cache
+object pointed to by strong ref never reclaimed%0A * use soft ref to point to object which is being cached (but can be dispensed)%0A * use weak ref to build weak collections, %0A *   to store metadata about obj only as long as they live%0A * use phantom ref to know if referent(obj being pointed to) has been gc'ed%0A *   get() always returns null%0A *   use for connection pool%0A * http://www.kdgregory.com/index.php?page=java.refobj%0A * https://www.ibm.com/developerworks/library/j-jtp01246/index.html%0A * https://www.ibm.com/developerworks/java/library/j-jtp11225/index.html
 %0A */

add notes on reference types