I have an RMI server client relationship (each running in a different JVM), and the RMI server creates a large object and returns it to the RMI client. After this is done which JVM (server or client) owns the actual memory for that object? If the object is passed between JVMs how is that done? Does it involve a disk hit, or is there some magic that makes it super fast?
Thanks
It depends on whether this large object is a remote object -- whether it indirectly implements java.rmi.Remote and is exported -- or if it's an ordinary serializable object, in which case it is copied from one JVM to the other. If it's the former, then it always stays in the JVM that created it. If it's the later, then it's copied from one to the other when it's passed as an argument to a remote method, or returned from a call to a remote method. The copies are plain, ordinary Java objects, and subject to being garbage collected at either end according to normal rules.