PAGE_READONLY May Be Used as Discardable Memory

Last reviewed: November 2, 1995
Article ID: Q94947
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1, 3.5, and 3.51
        - Microsoft Windows 95 version 4.0
    

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 "dirty," 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 "discarded," 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 reference words: 3.10 3.50 4.00 95
KBCategory: kbprg
KBSubcategory: BseMm


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.