Is there a way to swap back in (to put back all the memory data that was put into the page file (or swap, whatever you prefer)) memory on a windows PC?

On linux, one can easily do this with the swapoff /dev/sdaX, where X is the swap partition. On windows, it seems to ask me to reboot each time..

The reason I'd like to do this, is that, even though swapping out the data to the swap file allows me to play a resource-hungry game fully in physical ram, when I stop the game, all the rest of my programs run slow. This is or course normal; all the programs were pushed into the page file because my RAM was too small, and all memory access to those programs after gaming bumps into hard page faults, with major delays and some frustration as a consequence.

However, that frustration could easily be avoided, by simply allowing the PC to copy all data back into the physical memory for a minute or so, and then resume working on a fast working PC! (rather than having to endure the slowness -while- working)

Thanks in advance for any advice on this!

Kind regards

  • What you want is a "hypervisor" with multiple copies of Windows running on it. You suspend one and unsuspend the other. This is done quite a lot with other systems, but I'm not sure there's a hypervisor that can pull this off for Windows. – Daniel R Hicks May 2 '13 at 1:32

Unfortunately, no. The way Windows virtual memory system works, many of the pages simply can't be mapped until they fault and can't be stored in memory unless they're mapped. So Windows has to wait until the pages are accessed.

  • Maybe some sufficiently privileged third-party process could try and access those pages so they do fault? – badp Mar 9 '14 at 15:25
  • It wouldn't do much good for another process to access the pages. You need them faulted into the processes for the apps you're trying to use. – Jamie Hanrahan Jul 26 '14 at 22:10
  • Come to think of it, it could be done... sort of. You'd have to inject a remote thread into the target process. That thread would then do VirtualQuery on the address space and then simply read every process-private page. However there is no way to distinguish between pages that were in RAM and were later paged out, vs. pages that were never paged in in the first place. There would also be no way to identify pages the process will never need again. So you'd be paging in a lot of stuff that you didn't have to. – Jamie Hanrahan Mar 2 '15 at 7:52
  • @JamieHanrahan It sounds like that would work. – David Schwartz Mar 2 '15 at 8:20

Unfortunately there is no such option.

The only way to decrease swapping in Windows is to increase the physical RAM.

  • Or disable swap entirely. Not necessarily a windows thing, but on my Linux/BSD machines, I disable any forms of rotational swap because it does no good, and when things start to use it, instead of hitting a hard limit, they slow down everything. – killermist May 6 '13 at 22:11
  • Disabling the pagefile will not disable paging to disk. It will only disable page-out of private committed address space. Memory mapped file contents will still be paged in and out. – Jamie Hanrahan Aug 4 '14 at 7:40

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.