<commit_before>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");<commit_msg>add notes on reference types<commit_after>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;

/**
 * object pointed to by strong ref never reclaimed
 * use soft ref to point to object which is being cached (but can be dispensed)
 * use weak ref to build weak collections, 
 *   to store metadata about obj only as long as they live
 * use phantom ref to know if referent(obj being pointed to) has been gc'ed
 *   get() always returns null
 *   use for connection pool
 * http://www.kdgregory.com/index.php?page=java.refobj
 * https://www.ibm.com/developerworks/library/j-jtp01246/index.html
 * https://www.ibm.com/developerworks/java/library/j-jtp11225/index.html
 */
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");
{'fraction_non_alphanumeric': 0.12165450121654502, 'fraction_numerical': 0.0170316301703163, 'mean_word_length': 4.375816993464053, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3903513', 'n_tokens_mistral': 548, 'n_tokens_neox': 504, 'n_words': 149}