The API you need is called ExitProcess...... Seriously, I have known of apps where services are periodically shut down because of growing memory usage. Whether this will work in your situation is something you'll have to look at.
Doing everything right in .NET doesn't necessarily help. If you search Help & Support for "memory leak" you'll find plenty of hits on leaks in the underlying OS components (sometimes the framework), and if you're unlucky your service is inadvertently running into them. You first need to find out if what they're seeing is actually a leak, and then try to identify it from the .NET angle and maybe from the process angle if you can't identify something like leaked (unmanaged) resources in your code. It's not clear to me how the managed heaps inside a process are handled. More memory will be allocated as more objects get created, so managed heap size will increase, and so will the memory used by the process. Even if objects are released, does the memory used by managed heaps get freed? I suspect that reducing the size of a managed heap is a rare occurrence on a system with plenty of free memory, so the process statistics might be showing that a lot of memory is being used, but a large part of that memory might be managed heaps that aren't being fully used for managed objects. Perhaps peaks in managed memory usage cause managed heaps to grow larger but the actual heaps aren't reduced in size when objects are released, especially when there's no memory pressure on the system. There's this: http://blogs.msdn.com/ricom/archive/2004/12/10/279612.aspx Ironically, this: http://support.microsoft.com/kb/923299 Phil Wilson -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Ding Sent: Wednesday, September 05, 2007 10:17 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] l immediately release any unneeded memory Q: Why do you want to do it yourself? A: One customer noticed service process had a large number of pages in use and worried about a memory leak. Sincerely, Tracy Ding -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Steele Sent: Wednesday, September 05, 2007 9:40 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] l immediately release any unneeded memory No. The garbage collector handles that for you. If you're utilizing unmanaged resources (files handles, windows handles, etc...), implement the IDisposable interface to make sure you release the resources. Why do you want to do it yourself? --- Patrick Steele http://weblogs.asp.net/psteele -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Tracy Ding Sent: Wednesday, September 05, 2007 12:35 PM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: [ADVANCED-DOTNET] l immediately release any unneeded memory Is there some sort of .NET call that will immediately release any unneeded memory for service process? =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com