Forwarding message to Harmony list as it was rejected previously as spam probably due to ZIP attachement and links in body.

Removing zip attachement and links.

---------- Forwarded message ----------
From: FaeLLe <[EMAIL PROTECTED]>
Date: Aug 23, 2006 2:34 AM
Subject: Java Distributed Garbage Collection in RMI
To: "Morozova, Nadezhda" < [EMAIL PROTECTED]>
Cc: harmony-dev@incubator.apache.org

Hello Nadezha,

Been experimenting with the DGC interface of Java RMI and as far as I have understood there is no way to make a remote object be garbage collected other than invoke System.gc() and let it be collected over time.

I however notice that the internal calls can be tracked by setting the following system properties,

        System.setProperty("java.rmi.server.logCalls", "true");
        System.setProperty ("sun.rmi.dgc.logLevel", "VERBOSE");
        System.setProperty("sun.rmi.dgc.logCalls", "true");

What I was wondering is if you had any suggestions on how to actually ensure that the remote object has been collected. I tried placing System.out.println() statements in the finalize() and unreferenced() methods (the client also implements the Unreferenced interface) however it seems to generate no such output.

Neither do the internal rmi logs that should be displayed in output in verbose mode show any indication of this happening.

I have attached the code if you would be willing to examine it and let me know what I am not doing correctly. Ps. I have included them in zip format and as Java sources whichever is convinient for you.

TestDistributedGarbageCollection.java is the RMI server and the EchoClient.java is the RMI client.

Regards,

- Vikram Mohan

On 7/25/06, Morozova, Nadezhda < [EMAIL PROTECTED]> wrote:

Dear Virkam,

 

Thanks for your interest. I'd be happy to answer your questions, but I was wondering whether we can discuss things on the mailing list? Private discussion seems to be against the community spirit, and then, the questions you ask might be relevant to other community members J  

 

Best regards,

Nadya Morozova,

 


From: FaeLLe [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 25, 2006 2:27 PM
To: Morozova, Nadezhda
Subject: Java Garbage Collection

 

Hello Mr. Morozova,

First of all let me apologise for writing to you without knowning you or having talked to you before.

I obtained your email address from the Harmony mailing lists and noticed the document you released on the Harmony mailing list about plugging in a custom GC implementation.

The reason I am writing to you is that at the moment I am undergoing my Msc project at the University of Kent with my supervisor being Dr. Richard Jones and am working on an implementation of Birrell's distributed reference listing algorithm.

We have worked on a formalization of the algorithm (TOPLAS paper ) and my task is the implementation of it.

But I am confused as to what approach I would undertake towards the implementation as to what part of the current Java code holds the current algorithm etc. Is there any paper or resource you could point me to for garbage collector implementation.

Your document talks about implementing a GC written in C but I was wondering would it not be possible for me to merely edit the JDK source code under the JRL license for academic purposes and rewrite my own code merely editing the method content.

Your cooperation in this matter would be most appreciated.

Yours Sincierly,

- Vikram Mohan
  Msc. Distributed Systems and Networks
  University of Kent
  Canterbury, Kent
  UK
  +44-(0)77-37592552

package ukc.kent.ac.uk.dgc.test;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class EchoClient
{

	public EchoClient()
	{
		super();
	}

	public static void main(String[] args) throws Exception
	{
		System.setProperty("java.rmi.server.leaseValue", "500");
		System.setProperty("sun.rmi.dgc.server.gcInterval", "500");
		System.setProperty("sun.rmi.client.logCalls", "true");
		main1(args);
		Thread.sleep(10 * 500);
	}

	public static void main1(String[] args) throws Exception
	{
		Registry registry = LocateRegistry.getRegistry();
		EchoInterface stub = (EchoInterface) registry.lookup("Echo");
		String response = stub.echo("Real time in client: "
				+ System.currentTimeMillis());
		System.out.println("Response from server: " + response);
		System.gc();
	}

}
package ukc.kent.ac.uk.dgc.test;

import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.Unreferenced;

public class EchoTest extends UnicastRemoteObject implements EchoInterface,
		Unreferenced
{

//	private static final long serialVersionUID = 1L;

	public EchoTest() throws RemoteException
	{
		super();
	}

	public String echo(String msg) throws RemoteException
	{
		System.out.println(msg);
		return this.getClass() + " - Have said: " + msg;
	}

	public void finalize() throws Throwable
   	{
		super.finalize();
		   
		System.out.println("EchoTest finalize called");
	}

	public void unreferenced()
	{
		System.out.println("EchoTest unreferenced");
	}

}
package ukc.kent.ac.uk.dgc.test;

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface EchoInterface extends Remote
{

	public String echo(String msg) throws RemoteException;

}
package ukc.kent.ac.uk.dgc.test;

import java.io.IOException;
import java.lang.ref.WeakReference;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

//import junit.framework.TestCase;

public class TestDistributedGarbageCollector
{

	private Registry reg;

	public static void main(String[] args) throws Exception
	{
		TestDistributedGarbageCollector tdgc = new TestDistributedGarbageCollector();

		tdgc.init();
		tdgc.runDGCtest();
		System.out.println("Run GTC Test method complete");
		tdgc.shutdown();
	}

	protected void init() throws Exception
	{
		reg = LocateRegistry.createRegistry(1099);
	}

	protected void shutdown() throws Exception
	{
		UnicastRemoteObject.unexportObject(reg, true);

		reg = null;
		System.gc();

		System.exit(0);
	}

	private void runGc()
	{
		WeakReference wr = new WeakReference(new Integer(2));
		while (wr.get() != null)
		{
			System.gc();
		}
	}

	public void runDGCtest() throws NotBoundException, IOException,
			InterruptedException
	{
//		reg = LocateRegistry.createRegistry(1099);
		
		System.setProperty("java.rmi.server.leaseValue", "10");
		System.setProperty("sun.rmi.dgc.checkInterval", "5");
		System.setProperty("sun.rmi.dgc.server.gcInterval", "10");
		System.setProperty("java.rmi.server.logCalls", "true");
		System.setProperty("sun.rmi.dgc.logLevel", "VERBOSE");
		System.setProperty("sun.rmi.dgc.logCalls", "true");
		System.setProperty("java.rmi.server.randomIDs", "true");

		EchoInterface echoServer = new EchoTest();
		Naming.rebind("//127.0.0.1:1099/Echo", echoServer);
//		lookRef();

		try
		{
			Thread.sleep(10 * 1000);
		}
		catch (InterruptedException e1)
		{
			e1.printStackTrace();
		}
		Naming.unbind("//127.0.0.1:1099/Echo");
	}

	private void lookRef() throws IOException
	{
		ProcessBuilder pb = new ProcessBuilder(
				"java",
				"-cp",
				"",
				"ukc.kent.ac.uk.dgc.test.EchoClient");
		pb.redirectErrorStream();
		Process p = pb.start();
		p.destroy();
	}
}
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to