We use Enterprise Library 3.0 to access Oracle DB (microsoft oracle client).
What happens when I do not dispose a DbCommand instance after a stored procedure or function is called? Does .NET automatically garbage collect them?
Note that we do make sure that the transaction/connection gets closed and disposed properly.
C# – Is is necessary to dispose DbCommand after use
.netc++oracle
Related Question
- C# – When should I use a struct rather than a class in C#
- C# – Proper use of the IDisposable interface
- C# – Use of Finalize/Dispose method in C#
- C# – When to use .First and when to use .FirstOrDefault with LINQ
- C# – How and when to dispose/garbage collect a singleton instance
- C# – How and when to use ‘async’ and ‘await’
Best Solution
This is a duplicate, but I don't have time to find the original.
If it implements IDisposable, and if you created it, then you need to call Dispose on it. That's why the developer of the class made it implement IDisposable.
The garbage collector does not call Dispose on all IDisposable-implementing objects.