This week I've been working with the System.Diagnostics namespace and in particular the Process Class.
One of our windows services on our remote servers has a memory leak and we are currently using various diagnostics to try and find the source, in the mean time, as a quick fix, I've extended a system that we currently use to check the health of our distributed servers.
I use the Process Class to pull the Process.WorkingSet64 Property for the designated process and do a check against a sensible max value for the process memory.
The Process.WorkingSet64 property gets the amount of physical memory for the working process, the working set memory is generally what you see in the monitoring tools in Windows Server.
We use Pingdom to continually monitor the state of our servers. Every minute, pingdom hits our servers and and triggers several diagnostics checks. With my new check, In the event the memory starts to become a little on the bloated side, I take the server offline and pingdom will send out a text message to the designated support team to let them know that the server is down.
I'm hoping to create a stand alone re-usable version of this that I can build on in the coming months, once I have something up and running I'll post it on my GitHub account.