Re: IDisposable with managed code




Mark wrote:
If your class implements IDisposable, I was told that this increases the
speed with which your class is garbage collected. Is this true?

No, it is not true. IDisposable allows you some control over when
non-memory resources are released: file locks, memory allocated outside
the managed environment, handles to resources in the underlying O/S,
etc. IDisposable has no effect upon when the GC will reclaim memory.

If you have just released a very large memory structure and want to
hasten its collection, you should call GC.Collect(), but even this does
not guarantee immediate cleanup, it just makes it more likely.

.



Relevant Pages

  • Re: finalize() overhead
    ... non-memory resources less important than memory resources? ... But requiring explicit deallocation of non-memory resources ... framework for managing such an open-ended list of resources was ... on finalizeas a destructor substitute are doing themselves ...
    (comp.lang.java.programmer)
  • Re: finalize() overhead
    ... non-memory resources less important than memory resources? ... But requiring explicit deallocation of non-memory resources ... framework for managing such an open-ended list of resources was ... on finalizeas a destructor substitute are doing themselves ...
    (comp.lang.java.programmer)
  • Re: finalize() overhead
    ... non-memory resources less important than memory resources? ... But requiring explicit deallocation of non-memory resources ... Java does not have automatic destructors, ...
    (comp.lang.java.programmer)