Groups | Blog | Home
all groups > dotnet performance > march 2004 >

dotnet performance : Window GUI application Memory Issue


david
3/22/2004 5:20:27 PM
Hi,
I have a windows gui application. It has performance problem. It runs well
at morning.
But in the afternoon, System becomes slower then extremely slow until you
restart the computer.
I use .NET memory profiler to trace it.
I find Generation #2 keeps growing, never decreases.

I call "dispose" method for every form at the "Done" event.
Then set form to null.
like:

Form1.Dispose();
Form1 = null;

And I manully put GC.Collect() in the code. But it has no performance
change.

Is this a coding problem or something else?

Anyone can help?


Thanks in advance!

David

david
3/22/2004 5:53:55 PM
And in the memory profiler the disposed instances are listed properly,even
the textboxes,tabs, comboxlists.

David


[quoted text, click to view]

david
3/22/2004 6:04:49 PM
Matt,
How to check it?
is it in "real-time" -> "classes"?
If it's there, it's so strange.
The total instances are all the same as live instances (last gc).
It seems all my disposed objects are all alive???

What can I do next?

Thanks,
David




[quoted text, click to view]

Matt Davey
3/22/2004 10:50:12 PM
You essentially have a resource leak. Try running CLRProfiler/.NET Memory
Profile and seeing what objects are not being GC'd. If you can find out the
type of object, then you will find the leak.

Later
http://weblogs.asp.net/mdavey/


[quoted text, click to view]

david
3/23/2004 6:12:57 PM
Hi,
Following Matt's suggestion, I made big progress. Thanks again, Matt.

Now I narrowed the problem.

In my code, I have a global shared imagelist.

If I pass the imagelist to objects, the objects can not be released clearly,
it keeps reachable.

I tried to remove the imagelist from one of my objects, system release
memory perfectly.

I also tried to dispose imagelist,
but it can not be resused by other objects any more.


Any ideas?

Thanks,

David




[quoted text, click to view]

Niall
4/13/2004 2:38:04 PM
David,

If a static ImageList is your problem, be aware of the TabControl and the
ToolBar. Both of these hook onto evens in the ImageList you give them, and
they do not unhook when they are disposed. Hence, there will be a leak if
you use a static ImageList. What you need to do is to write a class that
inherits from the control, override Dispose and set the ImageList property
in the control to null, which will cause it to unhook the event.

This may be a problem for more controls than these, they're just the only
ones I've come across.

Niall

[quoted text, click to view]

AddThis Social Bookmark Button