Memory Leak with .NET 2.0 - any suggestions, or help?

D

Dante

I have encountered a memory leak in out application using .NET 2.0
while using our owner drawn controls. There are two instances I have
found when checking the memory using .NET Memory Profiler from SciTech,
both led to WeakReference leaks:

Graphics.DrawIconUnstretched()
the call stack is as follows:
Icon.DrawUnstretched(...);
WindowsGraphics.FromGraphics
WindowsGraphics.FromHdc();
DeviceContext.FromHdc()
DeviceContext.ctor()
DeviceContexts.AddDeviceContext()
ClientUtils.WeakRefCollection.Add()
ClientUtils.WeakRefCollection.CreateWeakRefObject()
ClientUtils.WeakRefCollection.WeakRefObject..ctor


Create a SolidBrush or a Pen had led to following call stack:
SolidBrush.ctor(Color)
SystemColorTracker.Add()


The created icon and the brush/pen are in a using block and should have
been released. I can not say for sure that this was previously working
with the .NET 1.1 Version but I have not seen this leak before and I
have done a lot of memory testing. The owner drawn controls are used
for a toolbar which is redrawn quite frequently as usual so the leak is
really serial.

Is there any MVP around that knows about this problem? I have seen only
one report mensioning the SystemColorTracker bug but there was no
positiv reply to it.

If there is no fix for it how good are the chances that it will be
fixed soon, lets say in the next 4 month?

We encountered yesterday another odd behaviour with our application
which was running several hours on a XP machine and is maybe related to
it: The application stopped drawing the controls and made a red "X"
instead. Our log file showed that when the application was trying to
create an icon it created an BufferedGraphicsContext exception, the
german error text to it is "BufferedGraphicsContext kann nicht entfernt
werden, da momentan ein Puffervorgang läuft." The Taskmanager showed
that the app was using over 9000! GDI-Objects - normally there are only
about 500.

Hope that I have provided enough informations to find someone out
therer who can help

Yours
Don
 
D

Dante

New Year - new hope ....

.... that someone reads this message and has an idea or solution to the
problem. As long as you are using build in controls this behaviour
might not happen but if you want to create a cool looking application
you are lost, aren't you?

Ciao
Dante
 

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