[let's add prefix to the subject line]
Hi Vikram,
I've attached test.txt file containing all necessary java sources as well as test output on Harmony (actually, it's the same on RMI also).
Regards,
Mikhail
On 8/23/06, FaeLLe <[EMAIL PROTECTED]> wrote:
Hello Mikhail,
Thanks for the reply !
However your email only contained the attachement of the output do not see
the modified sources. If you could reply with them it would be nice.
Thanks,
- Vikram Mohan
On 8/23/06, Mikhail Markov <[EMAIL PROTECTED] > wrote:
>
> Hi Vikram,
>
> First of all, what rmi module are you using: rmi or rmi2? rmi module does
> not support sun.* properties. Instead it supports a parallel structure of
> harmony.* ones.
>
> About your question about DGC (i'll use rmi module as an example):
> Remote object (on server side!) could be collected if all the conditions
> below are met:
> 1) (Of course) no hard references in local VM
> 2) no remote references from from other VMs
> 3) no in-progress remoted calls
>
> Here is one of the simplest test scenarious showing how to check these
> conditions:
>
> - run rmi-registry in separate VM
> - export remote object, register it in the registry and remove hard
> references to this object
> - kill rmi-registry VM
> - wait for a period of time longer than the one specified by "
> java.rmi.dgc.leaseValue" property (the default is 10 min)
> - if remote object implements Unreferenced then it's unreferenced() method
> should be called here
> - run GC - the object should be collected and it's finalize() method
> should be called
>
> I think your code is doing a lot of extra staff so i've modified it to
> implement this test scenarious (see attachment).
> I did not use ProcessBuilder class as Harmony does not have it yet. The
> output of the test is also attached.
>
> Hope this helps.
>
> Regards, Mikhail
> Intel MIddleware Products Division
>
>
>
> > > 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
> >
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
www.FaeLLe.com
www.VikramMohan.com
EchoInterface.java: ------------------ import java.rmi.Remote; import java.rmi.RemoteException;
public interface EchoInterface extends Remote {
public String echo(String msg) throws RemoteException;
}
------------------------------------------------------------------
EchoObject.java:
---------------
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.Unreferenced;
public class EchoObject implements EchoInterface, Unreferenced {
public EchoObject() throws RemoteException {
UnicastRemoteObject.exportObject(this);
}
public String echo(String msg) throws RemoteException {
System.out.println(msg);
return this.getClass() + " - Have said: " + msg;
}
public void unreferenced() {
System.out.println("EchoObject unreferenced");
}
public void finalize() throws Throwable {
super.finalize();
System.out.println("EchoObject finalized");
}
}
------------------------------------------------------------------
RMIRegistryStarter.java:
-----------------------
import java.rmi.registry.LocateRegistry;
public class RMIRegistryStarter {
public static void main(String[] args) throws Exception {
// time to sleep after rmiregistry creation
//int sleepTime = args[0];
// create registry
LocateRegistry.createRegistry(1099);
// wait for 1 s and then exit
Thread.sleep(1000);
System.exit(0);
}
}
------------------------------------------------------------------
Test.java:
---------
import java.rmi.Naming;
import java.rmi.server.RemoteObject;
public class Test {
public static void main(String[] args) throws Exception {
System.setProperty("java.rmi.dgc.leaseValue", "1000");
System.setProperty("harmony.rmi.dgc.checkInterval", "500");
// export remote object
EchoObject echoServer = new EchoObject();
// start rmiregistry in another VM (VM2)
Runtime.getRuntime().exec("/jdk/harmony/jdk/jre/bin/java.exe
RMIRegistryStarter");
// register exported object in rmiregistry
Naming.bind("//127.0.0.1:1099/Echo", RemoteObject.toStub(echoServer));
// clear hard reference to the exported object in this VM
echoServer = null;
System.out.println("Test: ready");
// wait till rmiregistry VM exits
Thread.sleep(1200);
System.out.println("Test: VM2 exited");
// wait for a while to let the lease expire
Thread.sleep(1000);
System.out.println("Test: sleep finished");
// call GC
System.gc();
}
}
------------------------------------------------------------------
Output on Harmony:
-----------------
Test: ready
Test: VM2 destroyed
EchoObject unreferenced
Test: sleep finished
EchoObject finalized
--------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
