title: Does the Java VM move objects in memory, and if so - how?
body: <p>Does the Java virtual machine ever move objects in memory, and if so, how does it handle updating references to the moved object?</p>
  
  <p>I ask because I'm exploring an idea of storing objects in a distributed fashion (ie. across multiple servers), but I need the ability to move objects between servers for efficiency reasons.  Objects need to be able to contain pointers to each-other, even to objects on remote servers.  I'm trying to think of the best way to update references to moved objects.</p>
  
  <p>My two ideas so far are:</p>
  
  <ol>
  <li>Maintain a reference indirection somewhere that doesn't move for the lifetime of the object, which we update if the object moves.  But - how are these indirections managed?</li>
  <li>Keep a list of reverse-references with each object, so we know what has to be updated if the object is moved.  Of course, this creates a performance overhead.</li>
  </ol>
  
  <p>I'd be interested in feedback on these approaches, and any suggestions for alternative approaches.</p>