Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Dispose on Kill process

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Carlisle - 28 Nov 2006 04:35 GMT
Hi,

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.

The only way I can think of doing this currently is by using windows
messages to catch the destroy message. From what I've read CLR doesn't appear
to be notified when this happens.

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)

Thanks,

Mike
Peter Duniho - 28 Nov 2006 05:10 GMT
> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.