Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

rmi objects are garbage collecting  RSS feed

 
vidhyasagar reddy
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi every body
as soon as am starting my applications and which creates remote references
through rmi it is giving that the server object is not having any remote reference.

i found no references
>by implementing the unreferenced interface


my dbts are:

>java.rmi.dg.leaseValue is 10 mins by default
i increased this value and tried hold references but no use
>but when i do above using the simple dummy interface it is working fine
but not in my application
>i didn't override this varibale any where in my application

can any body suggest me wt could be the problem?
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two things you need to do to keep the garbage collector at bay:

1. Keep a live reference to the remote reference.
2. Keep the main Class alive.


1. Make sure the start up class always holds a live reference to the implementation class. Don't just export the remote object. Keep a live reference to it.

2. Never end the server:


// object for monitor
Object forever = new Object();

// lock object
synchronized (forever) {

try {
// wait forever
forever.wait();

} // end-try

catch (InterruptedException e) {
} // end-catch
} // end-sync
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!