Discussion:
Stopping Service when Memory reaches 2 GB
(too old to reply)
FB
2009-07-06 17:27:01 UTC
Permalink
We have an App and when it reaches 2 GB of RAM begins to behaviour erractly.
The only solutions is to restar the corresponding service and everything is
fine again. It´s a Leaky App and te deveoper know about and don´t do anything
about it.

We need to create a Script to:

1) Check if the the APP is "eating" all memory (2 GB is the limit, so,
monitoring when the App reaches 1.7 GB of RAM, it´s fine)

2) If so, we need to test if someone is connected (netstat -na | find
":1443" does the Job)

3) If nobody is connected, the Service can be restarted.


Wich "language" is more suitable for this?

Batch? VBS/WMI? PowerShell?

Batch can use neststat, find, tasklist and sc/net

PowerSchell can use Get-Service and Stop-Service to to the Job, but theres
no ways to obtain the "netstat" info to decide if the service can be
restarted.


VBS/WMI is very complex of rmy skills...

Someone can help me?
Pegasus [MVP]
2009-07-06 18:54:08 UTC
Permalink
Post by FB
We have an App and when it reaches 2 GB of RAM begins to behaviour erractly.
The only solutions is to restar the corresponding service and everything is
fine again. ItŽs a Leaky App and te deveoper know about and donŽt do
anything
about it.
1) Check if the the APP is "eating" all memory (2 GB is the limit, so,
monitoring when the App reaches 1.7 GB of RAM, itŽs fine)
2) If so, we need to test if someone is connected (netstat -na | find
":1443" does the Job)
3) If nobody is connected, the Service can be restarted.
Wich "language" is more suitable for this?
Batch? VBS/WMI? PowerShell?
Batch can use neststat, find, tasklist and sc/net
PowerSchell can use Get-Service and Stop-Service to to the Job, but theres
no ways to obtain the "netstat" info to decide if the service can be
restarted.
VBS/WMI is very complex of rmy skills...
Someone can help me?
I would use a batch file, e.g. something like this:
@echo off
set app=Firefox
for /F "tokens=5" %%a in ('tasklist.exe ^| find /i "%app%"') do set mem=%%a
set mem=000000000%mem:,=%
if %mem:~-12% GTR 000001700000 goto :eof
netstat . . .
net stop . . .
net start . . .

Loading...