[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
long rant about java
OK -- for the sake of my own sanity (and, if this email ever gets indexed
by google, perhaps another thesis-writer out there) here is a brief rant
about Java RMI, the clone() method, and shallow vs deep copies of objects.
It turns out that you CAN'T pass around references to objects over Java
RMI in certain random ways. For example, if you use a Route object (which
contains pointers to Space objects) to compactly represent route
constraints and then pass it to a location server over Java RMI, this
causes bad things to happen -- namely because the server ALSO has copies
of Spaces locally. It turns out that RMI just plain freaks out if you pass
the same object a few times between the same two programs.
Here's an analogy:
Luka: Patrick, hold this thing for me.
Patrick: OK.
...
Luka: Patrick, can I have my thing back?
Patrick: OK.
Luka: Patrick, can I have my thing which I am currently holding?
Patrick: OH NO! I am OUT OF MEMORY!
Luka: NO THESIS FOR YOU!
Lesson learned: if you get random Java.lang.outOfMemory errors when you
are passing around, at most, a 2k object over RMI, this is probably what
is happening. The solution: use strings, or make deep copies of objects
with clone() or something.
The end.
Patrick
--
* * *
Patrick James Nichols II
Graduate Student, MIT Computer Graphics Group
http://graphics.csail.mit.edu/~pnichols