Set an application's resource limits (CPU usage) - windows

It's a little strange I know,
but I want to limit a program (for example the winrar app) resource usage.
The reason:
I have an old laptop, with overheating problem, so if I want to do a calculate intensive task (compress a >10GB folder), my laptop overheats and turns off.
The question:
Is it possible to limit an application's resource/CPU usage? For example, can I set somehow, that winrar can only use my CPU's 50%?
I use windows 8.1,
but answer for other OS is welcome.

See Are there solutions that can limit the CPU usage of a process? for general answer.
WinRAR itself has the command line switch -ri, see in help of WinRAR the page with title:
Switch -RI<p>[:<s>] - set priority and sleep time
For example using a command line like
WinRAR.exe a -ri1:100 Backup.rar *
results in compressing all files in current working directory with default settings using lowest task priority and with 100 ms sleep time between each read or write operation.

Related

hadoop fair scheduler open file error?

I am testing the fair scheduler mode for job assigning, however I get such error
java.io.IOException: Cannot run program "bash": java.io.IOException: error=24, Too many open files
After a google, Most of them will tell to check how many files are currently open in the system (by unix command lsof) and how's that number related to your system limit (check by bash command ulimit -n). Increasing maximum number of open files at a time is short-term solution in my opinion.
Is there anyway to avoid this?
The fact that your system is reaching the limit for #(max open files), you might have to check:
How many other operations are running on the system ?
Are they heavily opening many files ?
Is your hadoop job itself heavily opening many files ?
Is the current limit for #(max open files) too small on your system ? (you can google out the typical values). If its too small, consider increasing it
I think increasing the #(max open files) limit will work out. In long term you might again end up with that problem if #1,#2 and #3 are not addressed.

Test free mem in console on windows

It's pretty obvious on every platform to see the amount of free mem, but I need to get the value in a batch script.
good old mem command is limited to 64MB
What should I use?
You can use performance counters. There are a few ways to query performance counters from the command line. Probably the simplest way is with the typeperf command. The following example displays one sample (-sc 1) of the “Available Mbytes” counter from the “Memory” object on the “kennypc” computer.
typeperf "\\kennypc\memory\available mbytes" -sc 1
There are a variety of performance counters to choose from to get just the results you need. The Performance Monitor snap-in (perfmon.msc) can be used to browse through the available performance counters.
WMI can help.
wmic os get FreePhysicalMemory

Determining maximum memory use of a process

I want to run a command and, when it's complete, have a record of the maximum memory use of the resulting process. For instance, I want something analogous to the 'time' command on Linux, where 'time foo' will run 'foo' and, when 'foo' exits, will print out the amount of CPU time that 'foo' took.
For my present application I need this to run on Windows, but if you know of a Linux-only program let me know too. (At the very least it'd be interesting, but it may also give me a lead to find a Windows equivalent.)
You can, if you have Vista (maybe 7 too, not sure). Go to start -> control panel -> system and maintenance -> administrative tools -> Reliability and Performance Monitor -> Performance Monitor -> Create new watch (green + symbol) -> Process -> Working Set -> [select a process below] and press Ok. You can log this, etc.
Screenshot: http://www.freeimagehosting.net/image.php?912df44d75.jpg
I don't know of a program that does this, but there are APIs.
If you're using .NET, use the Process.TotalProcessorTime property.
If you're using native code, use the GetProcessTimes() function.
I've created a cmd exe for anaylsing memory usage of long time running program.
see here:MemoryUsageMonitor
I have created a simple Windows program called timemem.exe that behaves similarly to /usr/bin/time on Linux/Mac OS X, and will show similar statistics, such as elapsed time, user and kernel CPU time, and maximum working set size in memory used by another Win32 process. See:
http://homepage.mac.com/jafingerhut/files/code/code.html

Windows equivalent of ulimit -n

What is the windows equivalent of the unix command " ulimit -n" ?
Basically, i want to set the maximum fd limit via command prompt.
I don't believe that current Windows O/S have a limit on the total number of file descriptors, but the MS runtime library (msvcrt.dll) has a per process limit of 2048, albeit as far as I know that's not enforced by the O/S.
It can allegedly be increased only by building your own version of the MS runtime library from source.
hmm... I may have been wrong before - setmaxstdio (see here) - but it is per-process, not system wide.
I may be wrong, but I didn't think there was a limit to set in Windows... but unless you can say how this relates to programming, I expect this answer will be closed soon.
If you are in the "IT Pro" area (rather than development), then there is a sister-site, serverfault.com - coming soon for this type of question.

System Resource Monitor/Graph

I'm looking for an app that does about the same thing at the Performance tab on Task Manager, but on a per-process basis and with more plotted values. At a minimum, I would like to be able to plot CPU and memory usage but it would be nice if it could plot:
Network usage
File system IO (per drive/share sub headings would be nice)
Open file stream count
LSOF like stuff
All the other stats that the Process tab can give you
... anything else ...
Windows comes with perfmon which is pretty much exactly what you want. It has infinity different counters with different categories - also individual apps can register their own counters.
I worked with Norm at FS Walker Hughes, he made this and published it on CodeProject
What you exacly need is this => processstudio
Both have full source code available.
Enjoy!
Just use NAPI.

Resources