It\'s possible to create lots of memory-intensive objects and then abandon references to them. For example, I might want to download and operate on some data from a database
Ok, time to clear things up a bit (since my original post was a little muddy).
IDisposable has nothing to do with Memory Management. IDisposable
allows an object to clean up any native resources it might be holding on to. If an object implements IDisposable
, you should be sure to either use a using
block or call Dispose()
when you're finished with it.
As for defining memory-intensive objects and then losing the references to them, that's how the Garbage Collector works. It's a good thing. Let it happen and let the Garbage Collector do its job.
...so, to answer your question, No. It is not a bad practice to depend on the .NET Garbage Collector. Quite the opposite in fact.