Hopefully someone can set me straight. I am finding that a large .NET 1.1 application that we are upgrading to .NET 2.0 is using a HUGE amount of memory - specifically, opening and closing a form over and over causes memory consumption to jump every time.
I have started to use the .NET memory profiler, and see that events that are registered in the form seem to be the cause - but I'm not 100% sure.
So my question is, when you register an event handler (e.g. button click), what are the requirements for unregistering? If the event is registered through the designer (InitializeComponent), does that event need to be unregistered in 'Dispose'? If the event is registered in user defined code, does it need to be unregistered in 'Dispose'?
If you manually add event handlers then you need to analyse whether you need to explicitly remove them. Of course, if you know when the event handlers can be removed, it doesn't hurt to always remove them.
SciTech Software AB
Users browsing this forum: No registered users and 27 guests