Auto-kill process when exceeding 80% memory consumtion - Windows 2003 server

I need somehow to set the OS to autokill itself a process (dllhost) when it exceeds 80% of the system memory before it crashes, im using windows 2003 server.

Is there any quick or easy way of doing it??
LVL 1
celticianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam LeinssServer SpecialistCommented:
You might want to use ProcDump to investigate why it is going to 80%: https://technet.microsoft.com/en-us/sysinternals/dd996900.aspx

I guess you could use ProcDump to generate a dump, then use a loop or watcher function batch file to see when ProcDump exits and then kill dllhost based on its exiting, but I don't think that is a long term solution.
0
celticianAuthor Commented:
No no, its not a long term solution is just for 2-3 months until we have the new server running, thats why i need a quick blunder :)
0
celticianAuthor Commented:
I'm checking how to set up ProcDumb and y really can't find the arguments and how to make it watch the process memory usage evolution

the process i need to watch is dllhost

i need to kill it when memory usage is over 1,5 GB or either 80% of full memory available

i know there can be several dllhost process runing at the same time with different pid values, so i don't know how to handle this. i dont want a debug as this server will be shut down in a few weeks time...

C:\>procdump dllhost ???
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

R TCommented:
AnVir might meet your needs if you want a 3rd party tool:

http://www.anvir.com/

There's a free version and pro version.

*edit:  It might not support 2K3, but it supports XP so I'd give it a shot anyway, since the server seems like it's going bye-bye soon.
0
Adam LeinssServer SpecialistCommented:
@echo off
for /f "tokens=2 delims==" %%a in ('"wmic path Win32_PerfFormattedData_PerfProc_Process Where Name='dllhost.exe' get PercentProcessorTime /value 2>NUL | find /i "PercentProcessorTime""') do set usage=%%a
if %usage% GEQ 80 (
    taskkill /im dllhost
) else (
    echo Not yet...
)

Open in new window


Based on http://superuser.com/questions/619809/i-need-a-batch-file-that-will-be-able-to-restart-an-exe-when-the-exe-only-uses-1
0
celticianAuthor Commented:
Adam:

So what should i do with this piece of code?? How often will this be executed? Im a little puzzled.

Will this write in the else any kind of log, if not whats the point of echoing?

@echo off
for /f "tokens=2 delims==" %%a in ('"wmic path Win32_PerfFormattedData_PerfProc_Process Where Name='dllhost.exe' get PercentProcessorTime /value 2>NUL | find /i "PercentProcessorTime""') do set usage=%%a
if %usage% GEQ 80 (
    taskkill /im dllhost
) else (
    echo "usage at %usage% at %time%"
)
0
Adam LeinssServer SpecialistCommented:
It's running in a loop all the time...you don't have to do anything in the else cause, in fact it can be removed completely.  You should just open it once and that is it.
0
celticianAuthor Commented:
ok so i just store it in a .bat file and execute it from the prompt?
0
Adam LeinssServer SpecialistCommented:
:loop
@echo off
for /f "tokens=2 delims==" %%a in ('"wmic path Win32_PerfFormattedData_PerfProc_Process Where Name='dllhost.exe' get PercentProcessorTime /value 2>NUL | find /i "PercentProcessorTime""') do set usage=%%a
if %usage% GEQ 80 (
    taskkill /im dllhost.exe
) else (
    echo "usage at %usage% at %time%"
)
goto loop

Open in new window


Try this.  I tested it and it only ran once, so I added a loop condition.  Yes, just copy and paste into notepad and save as .bat

To kill the running of it just do a CTRL-C and say yes to terminating batch file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
celticianAuthor Commented:
Ok i assume if dllhost is killed, another instance will be created by the system, or this won't cause any mess, right??
0
celticianAuthor Commented:
I have some few more questions about this ill treat apart
0
Adam LeinssServer SpecialistCommented:
Well, it's unpredictable what will happen.  All instances of dllhost will be killed.  It's just looking at the overall CPU usage of the system and killing all instances of dllhost when CPU usage reaches 80%.  Now, when the system is running, you can run Process Explorer (https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx) and drill into dllhost and try to figure out what is exactly running as part of this process.  I just checked my Windows 8.1 system and I do not have dllhost as a running process, so it must be some 3rd program program that is running on your server causing the issue.

Without knowing what exactly is running away with memory and CPU, it's hard to guess what advice to give.  If it's the antivirus software on the server, you could disable this as you state it will only be around a few more weeks.  Or if the server only used during normal business hours (8 to 5), you could use the task scheduler and have it restart every night to clear out the memory.

Personally, I had a server running Windows Server 2003 that was 8 years old.  After a few weeks, the memory available would drop to zero due to SQL hogging it all.  I would just periodically reboot it after hours.  We replaced that server about a year ago.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.