tags:

views:

81

answers:

4

Hello, I have a windows service that runs 24x7 and the memory usage climbs steadily and about once a week we have to restart it.

I'm looking for information on understanding memory usage in .NET so that I may get a clear understanding of why our service is doing this.

I'd also like to gain a better understanding of this in .NET going forward.

Anybody got any good links?

THanks

+3  A: 

I haven't got any links, but it sounds like you have a memory leak somewhere - though I'm struggling to see how this would be introduced specifically on a weekly basis. Does your service register events in code? These are quite often gotcha memory leaks (the object that registered the event has been garbage collected, but the handler was not unregistered).

http://stackoverflow.com/questions/448197/unregistered-event-handlers-cause-memory-leak

Adam
+1  A: 

What you're seeing is called a Memory Leak. There's plenty of resources available online. I'm not sure this is a valid question, unless you want to provide some of the code for us to identify the leaks.

JustLoren
+2  A: 

Well, it's kind of simple: the GC runs every now and then and removes dead objects. An object is considered dead when no live reference points to it. Life references are determined by starting at the roots (e.g. static variables, CPU registers, etc.) and traversing all the objects. All objects not reached by this are dead.

So to address you problem you should use a memory profiler and check what objects are staying in memory, for instance caused by having a static dictionary which "caches" values and such.

Lucero
A: 

http://www.eqatec.com/tools/profiler/ <= free

Pierre 303
Won't help - that's not a memory allocation profiler.
Lucero