Originally introduced in Enterprise and Datacenter editions of Windows Server 2003, this feature is now in-box for Standard and upwards SKUs of Windows Server 2008.
As with other features, it is added through Server Manager / Features > Add Feature, and is cunningly named “Windows System Resource Manager” – note that it has a pre-requisite of the “Windows Internal Database” feature which it will install for you too.
A shortcut is also placed in the Administrative Tools folder – when you fire it up you specify which server you are managing (default is Local Computer).
So what does it do?
The service uses Windows Management Instrumentation to monitor processes running and keep an eye on their virtual and physical (working set) memory size, plus the amount of overall processor power it can use as an upper limit (note this is not a reservation, but a QoS-type guarantee).
There is one Managing Policy which is active at any given time by the system, you can however create as many as you like under “Resource Allocation Policies” in the MMC.
A policy contains, on its Resources tab, references to “Process Matching Criteria” values – in the properties of each of these references there are tabs for General and Memory which are of interest.
The General tab determines how the processor power not considered “residual” is to be shared assuming everything wants to use all available power – to prevent hanging the server or crippling services beyond belief the Residual criteria may not be removed and has a minimum of 1% (this comes from the implicit inclusion of “Equal_Per_Process”).
On the Memory tab of the resource allocation you can specify the maximum committed memory (virtual size in MB) and have the choice of either logging on event or stopping the application if it hits the threshold – it is also possible to specify the maximum working set for the process in MB too, which will make the Memory Manager kick in earlier to start it paging to disk (rather than killing the process).
The “Process Matching Criteria” I referred to are a set of rules defining files/command line and users/groups to which they apply (specifying no user or group will make the rule apply to all).
Too much theory, not enough screenshots… here is the UI with the properties of a Process Matching Criteria viewed…
…and here are the (General) properties of the Resource Allocation Policy associated with this criteria (also visible from the Dependencies tab of the criteria itself, so you can see who refers to it)…
…and the Memory tab looks like this…
So in the somewhat pointless example above, the policy Limit_VM_256MB will give preference to the CPU utilization of calc.exe, for members of Users only, up to 99% of available, but stop the process if its virtual size hits 256MB.
(Note that CPU utilization management only kicks in when the total reaches 70%, there is no point in restricting this resource if it’s far from being in contention.)
The screenshots were taken from Windows Server 2008 R2.
A more detailed look into WSRM is available on TechNet – and if you have added the feature then the help topics are pretty useful from within the MMC itself (for instance I didn’t go into the Profiling Policy, Calendar, Accounting, Computer Groups).
Is it possible to limit the total memory used by the user to a given amount? Not per process, but per user so it does not matter what the user decides to do he will be limited to X GB of memory.
There is a predefined policy you can see in the screenshot "Equal_Per_User", so the Memory tab on that Resource Allocation might achieve what you need?