0

I look for ways or solution to process memory overflow. Possibly restart service when memory overflow or when it grows above some value. Make some work before it die.

I know that is not normal situation and all errors leeds memory overflow needs to be corrected, but I need to be shure that after some issue service will recovered.

UPD I have windows service. This server accepts many connections from clients. Clients make some actions that leeds to memory consumption. Not leak, it just eat memory to process clients reqierments. At some moments (peak load) RAM is not enough. This is not big problem. The problem is that after first memory overflow exception service can't process anything. I have logs full of memory overflow exception. It not self restarting, it not processing clients requests, it not exit from this state.

I just want to find a ways to exit from this state of the service, and if it can not restart it. If it possible to predict such state.

The first way is limit clients, but it not garanted that some client eat very much memory.

Is it posible to detect dangerous memory consumption and stop processing new clients, or correctly restart? Is it posible to selfrestart service if memory is over?

4

1 回答 1

1

内存溢出真的很难跟踪/处理。很可能您有某种内存泄漏。在 .NET 中创建内存泄漏仍然是可能的。您无法在编程级别上自己处理内存溢出,因为您在托管环境中工作,在该环境中,您可以通过垃圾收集来消除不再使用的资源。最好的办法是防止内存泄漏。如果您想在服务的内存消耗很高时重新启动服务,您需要使用某种管理包,例如 Microsoft SCOM,它是 Windows 的非常全面的工具。

检查这些线程也在 C# 中的内存泄漏

http://crazorsharp.blogspot.com/2009/03/net-memory-leaks-it-is-possible.html

我希望这会有所帮助

于 2013-02-20T16:51:27.057 回答