I am looking for memory leaks in a huge code base so going line by line and observing for every possible location of where an IDisposable is used without being put in a using
statement or without being disposed is not an option.
I am currently using NDepend with the query from this answer NDepend CQL Query for missing IDisposable implementation but that is not what I need. I need to know if an object is instantiated and later on not being disposed of. How to write a query in NDepend that will find those objects? Or if that is not possible then how to get a list of places where IDisposable objects are being instantiated?
IDisposable
that isn't disposed is not a memory leak. It merely delays finalization of resources. This can be bad enough in and of itself, but a true memory leak is one where objects are created and mistakenly kept referenced (disposable or not). It is probably even less feasible to detect something like this with a static checker than trackingIDisposable
s. – Gies