title: Spring BeanFactory loading and unloading
body: <ol>
  <li>When is a Spring container (XMLBeanFactory) gracefully unloaded by Spring? </li>
  <li>What happens when the application is running but the only handler to the BeanFactory goes out of scope?</li>
  <li>What is the ideal way to load a Spring Container? Is doing <code>handler = new BeanFactory()</code> the right approach?</li>
  </ol>
  
  <p><br>
  <strong>Update:</strong> <br>
  When container goes out of scope, we would indeed expect the close() method to be called which would in turn release all the held resources. But that does not happen! I encountered a case where I had spring containers going out of scope but still memory getting full (OutOfMemory error). The reason was that the SessionFactory objects created by my Spring containers never got garbage collected as they are created as static. This implies that <code>close()-&gt;destroy()</code> was never called when containers went out of scope. Makes me believe that there is a leak issue with Spring itself.</p>