2

is there a way or program that allows me to disable the pagefile only to a program?

I don't want to disable it globally and I don't want to restart the computer every time I disable it

2 Answers 2

0

Although it's possible to make a program unpageable, I'm not aware of any easy end-user 'OS configuration option' kind of way.

At code-level though, when developing the application, one could do as described in this StackOverflow question How to prevent paging for one program / process?, and altough that's for Linux, windows has a very similar-purpused mechanism, such as the one described in How to lock pages in memory using WinAPI?.

Here's the relevant WinAPI reference documentation.

And there are yet other ways, such as the alternatives described on this Microsoft Developer blog:

If you really want to lock memory, you can grant your process the SeLockMemoryPrivilege privilege and use the AWE functions to allocate non-pageable memory. Mind you, this is generally considered to be an anti-social thing to do on a paging system. The AWE functions were designed for large database programs that want to manage their paging manually.

Side note, if your concern would be for security reasons, the same article mentions this:

If you have relatively small chunks of sensitive data, the solution I've seen recommended is to use CryptProtectData and CryptUnprotectData. The encryption keys used by these functions are generated pseudo-randomly at boot time and are kept in kernel mode. (Therefore, nobody can ReadProcessMemory them, and they won't get captured by a user-mode crash dump.) Indeed, this is the mechanism that many components in Windows 2003 Server to reduce the exposure of sensitive information in the page file and hibernation file.

However, as you can see, those are all pretty much at code-level. And although theoretically one could code a third-party utility application that allowed you to enable those feature to any user program you want by hackish-ly injecting code, I'm again not aware of any such tool publicly released yet.


If you really need to prevent any pagination, the most practical approach is to disable the pagefile (guide).

But keep in mind it's a very useful part of the system, that has been getting even better, and overall improves your experience by making the OS more responsive, and usually there isn't really any need to disable it.

For more details, check out the many good answers on Should I disable swap file if I have lots of RAM or should I move it to a virtual RAM drive?.

-1

This is not possible.

Applications themselves do not and cannot access the pagefile. It is possible to read the pagefile for forensic purposes but this is quite out of the ordinary. Writing to the pagefile is strictly prohibited and enforced.

The pagefile is a system resource and used only by the system memory manager. The system memory manager will at it's discretion write infrequently used memory pages to the pagefile. This is not subject to outside control and even the process itself cannot prevent it.

1
  • 1
    >even the process itself cannot prevent it. This statement does not appear to be really true. Commented May 30, 2023 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .