celtician
asked on
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??
Is there any quick or easy way of doing it??
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 :)
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 ???
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 ???
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.
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.
@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...
)
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
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_Pe rfProc_Pro cess 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%"
)
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_Pe
if %usage% GEQ 80 (
taskkill /im dllhost
) else (
echo "usage at %usage% at %time%"
)
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.
ASKER
ok so i just store it in a .bat file and execute it from the prompt?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok i assume if dllhost is killed, another instance will be created by the system, or this won't cause any mess, right??
ASKER
I have some few more questions about this ill treat apart
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.
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.
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.