I am having a problem with memory in a windows service I created in c# vs2003. The service activates once a day and performs a large operation. Using the resource monitor I can see the service grow to several hundred megabytes which it does not release.
The service contains a timer which fires an event once a minute. That event calls a function called Harvest() every 24 hours. Several classes are called in Harvest which populate many ArrayLists, hence the size of the service. However, all these classes are declared locally within the scope of Harvest(). So when Harvest completes, they go out of scope, and the garbage collector should kick in within a reasonable amount of time.
The service ran at 2:00am and this morning at 9 the memory footprint was still several hundred megs. I've tried forcing the local variables to null, called GC.Collect(), even GC.ReRegisterForFinalize(object). Nothing worked.
None of the code called is unmanaged. Havest() locally instantiates wrapper classes around the SharePoint Portal 2003 object model, which is written in .NET. Obviously something is amiss with this but I can't figure out why when it goes out of scope it won't clean itself up. There are several Close() methods for some SharePoint objects, but calling them makes no difference (as this happens automatically when they go out of scope). I can even issue an iisreset which kills SharePoint but the memory footprint does not change.
Has anyone encountered a similar problem or used tools compatible with C# which could help?
Right now I am wishing I was writing in C++!
