I'm looking for Windows program or method to consume an arbitrary amount of RAM. Purpose is to test how another program behaves when it's an a reduced memory situation.


Are you asking from a programmer's point of view? I have nothing ready-made for that, but it looks trivial to create such "software" yourself.

For example, in C++ (no error-checking):

#include <iostream>

int main(int argc, char *argv[])
    int required_size = atoi(argv[1]);
    std::cout << "Hogging " << required_size << " bytes\n";
    char *memory_hog = new char[required_size];
    std::memset(memory_hog, 153, required_size);
    return 0;

Run it from the command line like hog.exe 1073741824 (that's how many bytes there are in gigabyte). You can find the process in task manager to make sure it uses about that amount of memory. Press any key in the terminal window to exit.

Or, perhaps even simpler, in Python: [install from python.org], open the terminal, type python to launch it, then something like this (for Python 3):

a = [123] * (1024*1024*1024//8)

Again, you can find Python in task manager to make sure that's about 1 gigabyte, give or take. Use Ctrl-Z + Enter to exit Python, or del a and then a = [123] * <some other number> to consume some other number of bytes.

UPD.: this answer mentions some tools to limit memory usage by a process, that could be more practical.

  • I wasn't thinking of coding something, which is why I asked here instead of S.O, but the python method is so easy I'm accepting it. Nov 21 '19 at 22:33

one method is to create a virtual machine.

Using Oracle virtual box or vmware workstation.

You can specify amount of RAM and CPU allocation easily.

Obviously too low and you will hurt performance.

You could

  1. Load your software inside the VM, and adjust it as needed.
  2. Create an empty VM of any size just to suck up that much memory. The VM has to be on to consume resources. If if the VM has no OS it will still consume the requested amount of RAM.
  • Thanks. A little heavy-weight for what I was thinking but do-able and straightforward. Nov 20 '19 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.