Microsoft KB Archive/94947

{|
 * width="100%"|

PAGE_READONLY May Be Used as Discardable Memory

 * }

Q94947

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), included with:
 * the operating system: Microsoft Windows NT, versions 3.1, 3.5, 3.51
 * Microsoft Windows 95

-

Virtual memory pages marked as PAGE_READONLY under Win32 may be used the way discardable segments of memory are used in Windows 3.1. These virtual memory pages are by default not &quot;dirty,&quot; so the system may use them (zeroing them first if necessary) without having to first write their contents to disk.

From a system resource perspective, PAGE_READONLY is treated similar to discardable memory under Windows 3.1 when the system needs to free up resources. From a programming standpoint, the system automatically re-reads the memory when the data is next accessed (for example, we attempt to access our page when it has been &quot;discarded,&quot; a page fault is generated, and the system reads it back in). Memory-mapped files are convenient for setting up this type of behavior.

If a PAGE_READONLY memory page becomes dirty [by changing the protection via VirtualProtect to PAGE_READWRITE, changing the data, and restoring PAGE_READONLY], the page will be written to disk before the system uses it.

Additional query words: 3.10 3.50 4.00

Keywords : kbOSWinNT310 kbOSWinNT350 kbOSWinNT351 kbOSWin95

Issue type :

Technology : kbAudDeveloper kbWin32sSearch kbWin32API