title: Will .Net call Dispose for me in this case?
body: <p>For what I've read on the Internet, you should always call dispose on <code>IDisposable</code> objects <strong>as soon as you no longer need them</strong>.</p>
  
  <p>This question is about a particular case where (for me) is obvious that <strong>objects should no longer be needed</strong> and perhaps .Net may call dispose for me.</p>
  
  <p>Case in point:</p>
  
  <pre><code>type Foo() =
      let disposable:IDisposable = // create an IDisposable
      ...
  </code></pre>
  
  <p>The question is: As soon as <code>foo</code> of type <code>Foo</code> becomes unreachable (candidate for garbage collection; no references pointing to it), will <code>disposable</code> get disposed?</p>
  
  <p>My guess is that <code>disposable</code> won't get disposed as soon as there are no references to <code>foo</code>, since there is no reference counting occurring in real time (AFAIK), but <em>maybe</em> when <code>foo</code> gets garbage collected .Net will dispose <code>disposable</code>.</p>
  
  <p>For now, I'm avoiding to create disposables in that location, since it is not completely clear to me who should call dispose and even if .Net called dispose, I don't know how soon it would happen.</p>