开发者

Understanding Memory Usage

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 w开发者_开发百科hy 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


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 is finished with, but the handler was not unregistered, meaning a live reference exists so the object cannot be garbage collected).

Unregistered event handlers cause memory leak


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜