title: Does a class hold references to its field objects?
body: <p>I am a bit confused GC aspect when it comes to the instance variables, especially fields.</p>
  
  <p>So, if an object holds references to its field objects, these won't be eligible for garbage collection until the object itself is. Since <a href="https://www.dynatrace.com/resources/ebooks/javabook/how-garbage-collection-works/" rel="nofollow noreferrer">Threads are GC roots</a> and every object must have been created on some Thread only, <a href="https://www.dynatrace.com/resources/ebooks/javabook/how-garbage-collection-works/" rel="nofollow noreferrer">thread won't let go of any objects created on it</a> and the entire object hierarchy from a Thread shall remain for a considerable time before getting garbage collected.</p>
  
  <p>On the other hand, if an object lets go of the field objects, calling a getter for these objects will end up in returning null later.</p>
  
  <p>So, what are the facts here?</p>
  
  <hr>
  
  <p><strong>Clarification for "field objects"(as asked in comments)</strong></p>
  
  <ul>
  <li>By field objects I mean, the field members of an object that are themselves objects</li>
  </ul>
  
  <hr>
  
  <p><strong>Edit 2: A bit more elaboration</strong></p>
  
  <p>So, you see Threads are execution units having representation in memory through the Thread object instance. Any code execution that is happening anywhere is happening on some Thread.</p>
  
  <p>How would this execution happen?</p>
  
  <p>Well, through the execution of some code in a method. What would that make this object created?</p>
  
  <ul>
  <li>A Local variable</li>
  </ul>
  
  <p>And, that would make it a GC root.</p>
  
  <p>Btw, for a method call, there is a stack for that particular call and this is what I have been referring to here.</p>