C# Windows Forms - GDI Leaks

L

lpinho

Hi All,

I'm a bit new to the windows forms world, about 95% of my work is
service related, I usualy make console applications, no graphic
interface, the maximum interaction with client is "Press X to stop
application".

Now, in the windows forms world my application gets bigger and bigger
whenever I open and close a window (I'm making a MDI application)

What I mean is, the number of GDI objects, the number of handles
raises, the VM memory, what must I do? Should .NET framework take care
of disposing all the graphic object no longer in use?

If not, what can I do to prevent this?

In my company we use Rational Purify to search for mem leaks in C++ or
C can I use it to check leaks in C#?

Thanks for all the help you can give me,

Luis Pinho
 
B

Bob Powell [MVP]

Are you using interop to drive Win32 Graphics? If you are they are subject
to the same restrictions vis-a-vis balancing the selection and deselection
of brushes, pens and so-on.

If you're using GDI+ are you releasing pens brushes and so-on or just
leaving them dangling as is shown in much of the MSDN documentation?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
B

Bruce Wood

If you are using ShowDialog() to open new windows, are you remembering
to .Dispose() of the form after you're done with it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top