Hi,
First - destroy (dispose) all allocated pens, brushes, icons etc.
If X implements IDisposable, and you got it through "new" operator - call
Dispose when you are going to abandon referenced object.
Second - more subtile problem - is dangling reference. If your program often
allocates new data structures (i.e. as response to client request), and you
store somewhere reference to this data structures (and you don't need them
after end of the request handling) they won't be freed by GC.
In C++ it would lead to exception when you access this reference, or stay
unnoticed if noone touch them.
In .Net it "eats" resources - you have or "nullify" all references, or use
WeakReference instead all but one reference if "nullifying" is too
complicated.
--
==============================
Alexander Arlievsky
sa***@mprest.com
"The best tools for debugging are brains"
==============================
"Michael Culley" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
"Valerie Hough" <su*****@hcs-usa.com> wrote in message
news:#p*************@TK2MSFTNGP12.phx.gbl... I would be particularly interested in any objects that should be
disposed of right after they are used (pens, fonts, arrays, brushes, etc)
Pens, brushes and fonts should be disposed of asap but I believe you can
rule these out because they will not use much memory. I can't remember exactly what happens when you run out of say a pen, it will
either throw an exception or just draw black. Either way, running out of pens, brushes or fonts will leave you with plenty of system
memory. I would be particularly interested in any objects that should be
disposed of right after they are used (pens, fonts, arrays, brushes, etc)
You need to dispose/close connections and data readers etc but I wouldn't
think this would be the problem either because they should dispose of themselves sooner or later (sooner if your system in running
out of memory).
Do you use images at all? I have a memory leak in one of my apps when
importing a large number of pictures into the database. I'm not sure what causes it as I haven't got around to looking at it yet.
--
Michael Culley