Is it possible to hint the Windows virtual-memory-manager to bring a particular process out of swap?

The situation I often find myself in is normally using about 50% of my RAM for all the normal programs, one in particular being an IDE for an embedded target, along with its associated debugger.

Then I leave a memory hungry process running - eg wireshark or something that's accumulating data over a weekend, everything gets swapped out - as they should. After the big process is finished, most processes are left in swap.

Then the sporadic pauses to swap the process back in cause problems with the debugger, presumably due to timing issues in the comms between IDE and the hardware-debugger. So control of the target device can be sporadic until enough attempts have brought the debug-data in the IDE back out of swap.

  • This is would be very useful! From the users' point of view, it is annoying to wait for the swapped off process after each click or user action. It would be much better to say: "unswap this process!", go for a coffee and return to a responsive system! – Innate Imunity is The Way Dec 11 '13 at 11:28
  • I'm not familiar with the specifics of the swapping process of Windows but is this something you're looking for? There should be a working binary example in the comments. – Rik Dec 12 '13 at 17:05
  • 1
    I once had a similar question, and wrote a program based on the answers I got on Stack Overflow. – Kerrek SB Dec 16 '13 at 23:37
  • @Kerrek, I tried compiling your code under MinGW and got errors on each read "Failed to read one byte from 0x161000, error 299 (0 bytes read)." Since I only have Windows at work I wasn't brave enough to run the random binary you attached so the problem could be in my compilation. – Greg Dec 17 '13 at 5:44
  • 1
    @KerrekSB, seems like minor problem. Maybe you are touching memory area which is not mapped? Anyway I think your answer deserves the bounty :) PS: the unswap seems much slower than it could be, compared to HDD speed. Seems that the bottleneck is somewhere else, but where? – Innate Imunity is The Way Dec 18 '13 at 11:07

KerrekSB developed a special tool for this purpose:


It is available on GiTHUB with binaries: https://github.com/louisdx/unpage

During the run, you get lots of errors "Failed to read one byte from 0x....000, error 299 (0 bytes read)", but it is not a problem, the tool works great.

  • "but it is a problem"? I don't think it's a problem. – Kerrek SB Dec 19 '13 at 11:16
  • Quote: "tool that tries to get all applications back into physical memory". With the poster's "memory hungry process" this might not work. – harrymc Dec 19 '13 at 11:46
  • @harrymc Quote from the question: After the big process is finished, most processes are left in swap.. So presumably he already ended the "memory hungry process". – Rik Dec 19 '13 at 12:01
  • @KerrekSB of course, that was a typo. Thanks :-) – Innate Imunity is The Way Dec 19 '13 at 13:42
  • @Tomas I found this. With my very limited knowledge of c++ i verified that for every failed access the page is indeed protected by the PAGE_GUARD-bit. I used if (meminfo.Protect > 50) { std::cerr << meminfo.Protect << " - " << PAGE_GUARD << std::endl; } just before the ReadProcessMemory-line. PAGE_GUARD is 256 and i got 260 with the failed pages. So it is possible to get rid of the errors. Somebody with some c++ and Paging knowledge needs to read up on the PAGE_GUARD bit. – Rik Dec 19 '13 at 14:52

You can use Process Lasso to give a process a Memory page priority :

Beginning with Windows Vista, each memory page has a priority ranging from 0 to 7. The Standby List is divided into eight lists that each handle pages of a different priority. When the Memory Manager wants to take a page from the Standby List, it takes pages from the low-priority lists first. "

Process Lasso can help manage memory priorities by allowing persistent memory priorities to be set for processes, so that their virtual memory pages are set to a specific priority each time run.

Process Lasso has two versions : free and commercial ($18.95 with trial).

  • I am afraid that you are answering completely different question. Giving process process a memory priority is different task, probably useless in the context OP and me sketched out: when you already have a process that is in swap and want to unswap it. You don't want to prevent it from going to swap. – Innate Imunity is The Way Dec 16 '13 at 22:39
  • @Tomas: That's not my understanding. The request is to prevent a given process from being swapped out. If the process itself is not programmed to lock its pages into memory, the next best solution is to give it the highest memory priority to make it less likely to be swapped out. – harrymc Dec 17 '13 at 6:14
  • 3
    @harrymc, OP says when the memory hog runs, "everything gets swapped out - as they should" so that is what the OP wants. It's just that on Monday morning he wants the important processes' working sets to be brought in all at once, not in dribs and drabs by page faulting over time. – mgkrebbs Dec 18 '13 at 0:15
  • @mgkrebbs: That's a different solution to the problem, which I believe is impossible to do. My solution is that if the IDE is never swapped out, then there is no need to swap it back in. The "memory hungry process" will just have a few megabytes less of RAM, which won't impact too much on its performance. – harrymc Dec 18 '13 at 12: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.