Is there a way to ensure a program occupies the page file instead of RAM?

0

I would like to have some control over which programs occupy RAM and which occupy the page file when RAM becomes limited. Perhaps some sort of prioritisation-based solution would work well.

I am unable to add more RAM or upgrade the device, and I desire to run a virtual machine on it despite it already being fairly RAM starved. The VM will mostly be operating unattended, so snappy performance is not a priority, and I would be happy for it to occupy page file space so that my precious RAM can be used on everything else.

I'm aware that Windows attempts to "intelligently" decide what should occupy RAM and what should be offloaded to the page file, but it's not intelligent enough and things begin to slow down, so some manual control here would be very beneficial.

All the questions/posts I've found relating to this topic wish to achieve the opposite of what I'm requesting (i.e. prevent the page file from being used).

Bren0man

Posted 2020-01-23T04:28:47.013

Reputation: 1

Program data goes into the swap file (it's actually a page file). Executable code already exists on disk as an exe file. So Windows will dump executable code from memory knowing it can reread it from the exe file. If there is no memory pressure executable code will be in memory. You can give recommendations to Windows see https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessworkingsetsize. Even if it not in main memory it will be in the file cache. Memory can be in program memory and the file cache and it only uses the memory it uses.

– Mark – 2020-01-23T05:56:26.503

@Mark that sounds like the beginnings of a great answer... – Mokubai – 2020-01-23T07:53:30.763

The subject is so large. – Mark – 2020-01-23T07:57:17.093

Answers

0

There is not much control in Windows of RAM usage.

One possibility is to reduce the priority of the process below normal, which will also reduce its priority for using the RAM. This can be done in Task Manager, by right-clicking the executable and using the "Set priority" sub-menu.

Another possibility is to use the open-source Process Hacker.

If a particular process is consuming an unusually large amount of RAM, right-click it and select "Reduce Working Set", and Process Hacker will ask Windows to trim this down to something more manageable.

This isn't a magic solution, and if the process is actively working and using that RAM, then the Working Set figure will start growing again pretty quickly.

harrymc

Posted 2020-01-23T04:28:47.013

Reputation: 306 093