title: java - How can Garbage Collector quickly know which objects do not have references to them any more?
body: <p>I understand that in Java, if an object doesn't have any references to it any more, the garbage collector will reclaim it back some time later.</p>
  
  <p>But how does the garbage collector know that an object has or has not references associated to it?</p>
  
  <p>Is garbage collector using some kind of hashmap or table?</p>
  
  <hr>
  
  <p><strong>Edit:</strong></p>
  
  <p>Please note that I am not asking how generally gc works. really, I am not asking that. </p>
  
  <p>I am asking <strong>specifically</strong> that How gc knows which objects are live and which are dead, with efficiencies. </p>
  
  <p>That's why I say in my question that is gc maintain some kind of hashmap or set, and consistently update the number of references an object has?</p>