Courtney, This issue has been discussed previously and, as Ian pointed out, the likely problem is not that the runtime holds a lot of live objects, but that free memory is not returned to the underlying OS.
You might want to use the following trick: public class MemoryManagement { private MemoryManagement() { } [System.Runtime.InteropServices.DllImport ("kernel32.dll")] private extern static int SetProcessWorkingSetSize (IntPtr hProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize); public static void SwapOutProcess() { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } } Works for me. It will basically 'flush out' anything unused from the RAM your process is holding into oblivion; this is the same effect you would notice with a GUI app when you minimize the application's main window. Don't call it too often, though; once at the end of your service startup (after you've initialized everything) and once after your nightly process has completed would probably be more than enough. And, tell me if it works (you can even do it by private email if you wish) because I'm interested in any implications; I've used it extensively in WinForms apps, but not with a service or IIS-hosted application. Kamen -----Original Message----- From: Moderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Courtney Smith Sent: 31 Юли 2003 г. 16:33 To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] windows service memory footprint Thanks to everyone for the replies. I've done everything short of calling the garbage collector which has been suggested against both in print and verbally. As for the SQL solution Russ suggest below, I think my collection of SQL stored procs that gets called to create my reports its more complicated than my SQL abilities to create on my own into one massive stored proc....I also need to make these into html emails, nicely formatted...something System.web.mail does very nicely for me to send out to from anywhere between 0 - 300 people per day. This isn't spam by any means. Its internal to our organization. :) It appears the memory usage depends on the quantity of the emails sent out that day but I'm destorying (setting to nothing) all of the DataSets and DataReaders used. As mentioned in a pervious post, it likes 7MB just to exists as a service in the Service Manager running a 24 hour timer. Courtney Date: Wed, 30 Jul 2003 09:37:38 -0700 From: Russell McClure <[EMAIL PROTECTED]> Subject: Re: windows service memory footprint Courtney, Just a thought (I'm assuming you are using SQL Server): you could actually leverage the SQL Server Agent to do what you describe. That way you wouldn't even need your own service. All you would need to do is to create a Job under the SQL Server Agent and specify the times that you want it to launch. Then add steps to the job that call the stored procedures and send emails etc. This would all be written in T-SQL. Anyway, if this sounds interesting, let me know and I can give you more detail if you want. Russ ===== Courtney Smith [EMAIL PROTECTED]