Is there a way to limit the memory a process uses in Win7 x64?

There is the Windows System Resource Manager, but this only applies to Windows Server 2008.

In general, this is NOT a good idea--the page file is meant to be used. Most processes don't know the limit of their physical memory, nor should they be required to care. It sounds like you should clean up programs using the resources, or invest in more memory--4GB is pretty standard nowadays, and more is better.


  • On Win7, open msconfig, then Boot panel => Advanced options => check Maximum memory and set the limit in the textbox below the checkbox => Restart. This limits the total memory usage.

  • Another way could be running a batch script in the background, monitoring the memory usages of processes and kill it if it eats too much memory.

I had a unwanted process (it downloads lots of Ads) consuming too much memory (always started by another program I use frequently). Here is the bat script I monitor and close it automatically.

@echo off
set prog="XXXX.exe"
:1
SET found=1 
(tasklist /FI "username eq <your username>" | find %prog% || set found=0) >nul 2>nul
if %found% EQU 1 (taskkill /f /im %prog%)
ping 0.0.0.1 -n 600 >nul 2>nul
goto 1

May someone can extend it to monitor any process.

  • If you wrote your own program, you can utilize the Job objects API

    A job can enforce limits such as working set size, process priority, and end-of-job time limit on each process that is associated with the job. If a process associated with a job attempts to increase its working set size or process priority from the limit established by the job, the function calls succeed but are silently ignored. A job can also set limits that trigger a notification when they are exceeded but allow the job to continue to run.


It appears that there is no native way to do this, as yet again, M$ treats its users like incompetent idiots that shouldn't be allowed to perform tasks that might actually make the entire system more stable or productive.

The only workaround might be what was suggested for running a batch script in background (technically that falls under 3rd party, as the script is written and run unofficially by another party), but this wouldn't "limit" the process per se, but would instead restart the process when it hits its max limit you impose.

The issues with a restarting script that you should consider are:

  1. You will be killing the process unexpectedly, which means it will be interrupted in whatever task it was performing.

  2. Corrupted files could be generated if a file were being written to when the process gets restarted. This can be alleviated if the process has its own file verification and rewrite contingencies (such as online games and Steam).

  3. Other sub-processes and threads will also be killed as a result, and could propagate the other issues listed here.

  4. If the process eats up RAM rather quickly, restarting the process might occur too often, rendering the process useless (file a critical bug report and stop using the software).

  5. Although the Software process is experiencing an unintentional memory leak, it is possible that the process has an internal policy of behavior when the system is low/depleted in RAM, such as when it ends up using the Pagefile. If it changes its behavior to reduce its footprint in this case, restarting the process ensures it will never enter this kind of "reduced" state of operation.

Another reason why the Linux Team got things right, but alas, Windows got the world's support in drivers and games first, so we have to outlive it.

BTW, I personally experience a MASSIVE memory leak in the Razer GameScannerService.exe process, where of my 16GB of 1800MHz memory (and my 5GHz CPU), within a few minutes it has already allocated nearly 2GB of RAM, and I have seen it climb all the way up to 9GB if I allowed it to.

Razer does nothing to fix this, despite the massive number of bug reports. Our only option is to disable the service in some way and live without our ability to have Razer auto-apply profiles to games or auto-discover new games that get installed.