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?