How can I control the lease period associated with a client's reference for my remote object?

Govind Seshadri

When a RMI client obtains a reference for the remote object, by default, the reference is live for 10 minutes. If there is no client activity before the lease term expires, the reference is considered to be invalid, and the remote object may be subject to garbage collection, presuming there are no other clients holding a live reference to it.

However, the lease term can be easily changed, and is controlled by the system property java.rmi.dgc.leaseValue.

For example:

java -Djava.rmi.dgc.leaseValue=300000 MyRemoteImpl

resets the lease term to 5 minutes. The lease period is indicated in milliseconds.

Note that for optimal performance, the lease term should not be set toa very small value. An active RMI client automatically renews the lease when it is halfway expired, and a very small lease term would cause the client to consume precious network resources in repeatedly renewing the lease.