7.11.4. Lifecycle

The lifecycle of instances is directed by a system of leases. A lease is requested by a client at unmarshalling of incoming object reference, the lease is renewed by the client periodically and returned by the client after the object reference is garbage collected. The lease duration is configured in system properties, default is 10 minutes. To prevent errors due to network delays, clients renew lease when half expired.

The Unreferenced interface can be used to receive a notification when all leases to an object expire. Exporting an object creates a weak reference. Leasing an object creates a strong reference. A remotely accessible object is therefore subject to garbage collection when it is neither leased remotely nor referenced locally.

public interface Unreferenced
{
  void unreferenced ();
}

Persistent objects can inherit from the Activatable class, which registers the object instance with the RMI daemon for later activation.