title: Java EE: garbage collection in servlet container
body: <p>In a servlet container, servlet 'S' is instantiated and has served a few requests. It has a dependency on an object 'O' so it created that object when 'S' was instantiated. The only reference to 'O' is through 'S'.</p>
  
  <p>After serving the first few requets, 'S' did not receive any requests for a long time. Now the question is: will 'S' be garbage collected, and 'O' along with it? </p>
  
  <p>Or in other words, is there some server object 'A' that refers to 'S' due to which it won't be garbage collected no matter if it served any requests in a long time? If there's some such object 'A', then who is referring to 'A' so 'A' isn't garbage collected and so on?</p>