Search code examples
javagarbage-collectionrmi

Garbage collection of null object returned from RMI methods



I have a RMI method that returns an object to the client. When the method is completed, another RMI call for garbage collector is made implicitly. If I return null object, would the GC still be called? I cannot find any text confirming this anywhere.
related: Does variable = null set it for garbage collection


Solution

  • There is no such thing as a null object. There is a null reference. In the case you mention there is nothing to garbage-collect.

    When the method is completed, another RMI call for garbage collector is made implicitly.

    I don't know what you mean by this. If you're referring to DGC, it doesn't work like that. If not, you're mistaken.