Information of dirty virtual memory pages

Martin Sedlmair 31 Reputation points
2022-02-09T23:04:16.157+00:00

To advise the memory manager to know better which pages should be preferred for paging I need to know which pages are dirty. Obviously I can get a lot of information QueryWorkingSet and QueryWorkingSetEx but what I do not get is if the page is dirty or not.

I need this because the memory manager has its own strategy of when and how to perform paging, but this paging doesn't fit my needs because in this case I really know better what needs to stay and what needs to be paged out.

Sometimes its also necessary to discard a page since its contents have invalidated and do not have to written to disk (DiscardVirtualMemory).

Also QueryVirtualMemoryInformation shows no sign of a dirty bit/flag.

Also I can not install a write watch and retrieve the contents with GetWriteWatch since when allocating MM-Files there is no flag to create the MM-File with the write watch.

The only open I see is that I have to track it myself which renders the application of MM-files useless.

Any help would be highly appreciated.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,411 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 9,101 Reputation points Microsoft Vendor
    2022-02-10T02:57:25.283+00:00

    Hi,

    Welcome to Microsoft Q&A!

    Information of dirty virtual memory pages

    The information is stored in the page table.

    A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses.

    Each page table entry (PTE) holds the mapping between a virtual address of a page and the address of a physical frame. There is also auxiliary information about the page such as a present bit, a dirty or modified bit, address space or process ID information, amongst others.

    I suggest you could refer to the thread: https://stackoverflow.com/questions/41433299/how-the-os-knows-a-page-is-dirty-in-mapped-memory

    Best Regards,

    Jeanine


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.