This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GC Problems... (2nd file)


Sorry, twitchy finger syndrome....

Here's the 2nd file...

Simon.,
-- 
--------------------------------------------------------------------------
         Simon Levitt, Principal Development Engineer @ WorldPay,
WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND  
   Simon.Levitt@worldpay.com   Ph:+44(0)1223 715151  F:+44(0)1223 715157
------------------------- http://www.worldpay.com/ -----------------------
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Vector;

public class Helper
{
	private static FileOutputStream debugOut = null;


	protected Helper()
	{
	}


	public static class GCThread extends Thread
	{
		public void run() {
			try {
				Runtime runtime = null;

				runtime = Runtime.getRuntime();
				while (true) {
					// System.err.println("Running GC: " + (runtime.totalMemory() - runtime.freeMemory()) + "/" + runtime.totalMemory());
					System.gc();
					// System.err.println("GC Ran    : " + (runtime.totalMemory() - runtime.freeMemory()) + "/" + runtime.totalMemory());
					//System.err.println("");
					Thread.sleep(100);
				}
			}
			catch (Exception _) {}
		}
	}

	private static GCThread check = null;
	
	public static void doInit(String debugFile)
	{
		if (debugFile != null) {
			try {
				debugOut = new FileOutputStream(debugFile);
				System.setErr(new PrintStream(debugOut));
			}
			catch (IOException _) {}
			System.err.println("System.errFile: " + debugFile);
			check = new GCThread();
			check.start();
		}
	}

}
// End of Helper.java

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]