Link to home
Create AccountLog in
Windows OS

Windows OS

--

Questions

--

Followers

Top Experts

Avatar of celtician
celtician🇦🇸

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??

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Adam LAdam L🇺🇸

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.

Avatar of celticianceltician🇦🇸

ASKER

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 :)

Avatar of celticianceltician🇦🇸

ASKER

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 ???

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of R TR T🇺🇸

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.

Avatar of Adam LAdam L🇺🇸

@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

Avatar of celticianceltician🇦🇸

ASKER

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%"
)

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Adam LAdam L🇺🇸

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.

Avatar of celticianceltician🇦🇸

ASKER

ok so i just store it in a .bat file and execute it from the prompt?

ASKER CERTIFIED SOLUTION
Avatar of Adam LAdam L🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of celticianceltician🇦🇸

ASKER

Ok i assume if dllhost is killed, another instance will be created by the system, or this won't cause any mess, right??

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of celticianceltician🇦🇸

ASKER

I have some few more questions about this ill treat apart

Avatar of Adam LAdam L🇺🇸

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.
Windows OS

Windows OS

--

Questions

--

Followers

Top Experts

This topic area includes legacy versions of Windows prior to Windows 2000: Windows 3/3.1, Windows 95 and Windows 98, plus any other Windows-related versions including Windows Mobile.