Among our developers, this has become institutional knowledge: always hold a reference to the service in a member field or as a local in a main() method that never returns.
Another strategy we've used is to hold a reference to the service in a Thread passed to Runtime.addShutdownHook(). That serves the dual purpose of keeping the service from being GC'd and enabling last-minute cleanup of a service that is not explicitly unregistered and unexported. In our code, we also use a manual unregister() method on each service that stops the JoinManager, unexports the service, and removes the shutdown hook. So, in this case the shutdown hook is a fail safe in case of a developer bug. Chris -----Original Message----- From: Peter Firmstone [mailto:[email protected]] Sent: Sunday, March 07, 2010 6:15 AM To: [email protected] Subject: Re: strange problem with DGC Hmm interesting, by default DGC is disabled and all exported Remote's are only referred to by a weak reference, unless the implementer holds a strong reference, when using DGC (discouraged for secure endpoints due to DOS attacks) the service will have a strong reference kept, while client remote references leases exist. However if there's an intervening period where there are no clients and no local strong reference the Remote object will be GC'd. ... <snip> ...
