Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debugging and disposed objects

Is there a way to keep track of undisposed objects while debugging? For example after breakpoint is hit, I'd look to view what developers have forgotten to clean up.

like image 828
Nickolodeon Avatar asked Oct 19 '25 11:10

Nickolodeon


1 Answers

Not directly.

However, you can add finalizers to your Disposable classes, and have the finalizers call a method attributed with [Conditional("DEBUG"] that logs/throws/notifies you when they are hit. This allows you to track when a Dispose() method was not called on an object at debug time, but at deployment, will just get finalized as normal.

like image 70
Reed Copsey Avatar answered Oct 22 '25 02:10

Reed Copsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!