.net - How do I check if my object is properly disposed? -


I wonder if there is a "move" that allows to know that one part is used in the O code The items that are made properly (completely), or, in other words, do not make memory leaks.

Let's say I have a container for GDI objects (or else I must clear it clearly)

  public class superpane {pen _ flat pen, _2 dpn, _3dpn; Public Superpane () {_flatPen = (Pen) Pen. Black. Clone (); _2DPen = (Pen) Pen. Black. Clone (); _3Define = (Pen) Pen. Black. Clone (); }}  

Now, as I need to clear GDI objects:

  public class superpane: idispozazal {pen _ flat pen, _2 dphen, _3dpn; Public Superpane () {_flatPen = (Pen) Pen. Black. Clone (); _2DPen = (Pen) Pen. Black. Clone (); _3Define = (Pen) Pen. Black. Clone (); } Public Zero () {if (_flatPen! = Null) {_flatPen.Dispose (); _flatPen = null; } // 'forget' a copy paste here, if instead should be _2Depen (_flatPen! = Null) {_flatPen.Dispose (); _flatPen = null; } If (_3digit! = Null) {_3Define. Dishes (); _3DPen = null; }}}  

If you add a new "disposable" object and forget to settle it, then such a situation may occur. How can I find my error, I mean, check out what was my superpane solution properly?

Do not think this is possible; The best you can do to get a profile (like) and measure it if you find that you are stressing (through the profiler), then there is something wrong.

In addition to using Proffer, I do not know any automated techniques that help you identify unwanted resources.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -