> Is it possible to catch event when a .net application process is killed in
> order to do the required cleanup? ie. task manager - kill process.
[quoted text clipped - 3 lines]
> appear
> to be notified when this happens.
No one is. When you kill a process, it's not permitted to execute any more
code. Windows itself will do some cleaning up, but any code in the process
being killed is no longer eligible to be run. That's what killing a process
is all about.
> Is there an alternative, and is it possible that not disposing can lead to
> memory leaks? I'm investigating an issue where this appears to be
> happening.
> Although the process is killed it looks like some components are still in
> memory (not confirmed)
I'm not entirely sure about that. There are certain kinds of event handlers
that are documented as having to be removed on exit explicitly, otherwise
some global system resources are lost. It may be that when a process is
killed, these resources do get lost. But the kinds of events that fall into
that category are far and few between. Even if that was a potential
problem, only certain, unusual programs would run into it.
That said, killing processes to stop them isn't a good idea. It's a last
resort, and not just because you might leak some memory. Killing a process
ought to be an abnormal situation, and happen infrequently enough that
rebooting the computer is a reasonable solution to any memory leaks that
might occur.
Pete