I have been implementing an RMI client/server system which needs to detect when clients are finished with their remote references. On Windows, the clients set the reference to null and call system.gc() which invokes the unreferenced method on the server. Under solaris however the unreferenced() method is not called (even if System.runFinalization() is called). Any ideas why?
- The unrferenced() method is only called when ALL clients no longer hold a reference to the remote object or when the lease time expires, (java.rmi.dgc.leaseValue.)
- The Registries, (RMI/JNDI) are clients. If you register your remote object with one of these, then your unreferenced() method will never be called.
- Since this is the purview of the Distributed Garbage Collector, each operating system may implement this differently.
We sell a framework for RMI Servers. We do not implement the Unreferenced interface.
We keep track of the idle period, that is - the time when no Client has called the Server. When this idle period reaches a threshold, the application may take some action, (such as deactivating, etc.) In this way, we are not dependent on any implementations of DGC and we have much more flexibility.