Java RMI 对象在内存中的位置
我有一个 RMI 服务器客户端关系(每个客户端都在不同的 JVM 中运行),RMI 服务器创建一个大对象并将其返回给 RMI 客户端。完成此操作后,哪个 JVM(服务器或客户端)拥有该对象的实际内存?如果对象在 JVM 之间传递,那是如何完成的?它是否涉及磁盘命中,或者是否有某种魔法使其变得超快?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于这个大对象是否是一个远程对象——它是否间接实现 java.rmi.Remote 并被导出——或者它是否是一个普通的可序列化对象,在这种情况下它是从一个对象复制的JVM 到另一个。如果是前者,那么它始终保留在创建它的 JVM 中。如果是后者,则当它作为参数传递给远程方法或从远程方法的调用返回时,它会从一个复制到另一个。这些副本是简单的、普通的 Java 对象,并且根据正常规则在两端进行垃圾收集。
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.