(v13) The Harlequin RIP on Windows
This page applies to Harlequin v13.1r0 and later; and to Harlequin Core but not Harlequin MultiRIP
This section describes the behavior of the RIP in abstract terms. On Windows, the two memory models described translate into behavior in this manner:
- When configuring the RIP with a single memory block allocation, the SDK example RIP wrappers use
VirtualAlloc(NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE)
to allocate the memory. All of the pages for the allocation are committed immediately. Windows does not allow more than the RAM size (physical plus swap size) to be committed at any time, so this guarantees that the RIP will be able to sub-allocate exactly this amount of memory. On the other hand, this also fixes this amount of memory so that other processes cannot use it, even when the RIP does not need the memory. - When configuring the RIP to use virtual memory, the main part of the RIP's address space is initially reserved using
VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS)
. This reserves address space, but does not commit physical pages to those addresses. When MPS needs to get new segments to fulfill allocations, it will useVirtualAlloc(base, addr, MEM_COMMIT, PAGE_EXECUTE_READWRITE)
to commit a physical page. When MPS can release segments, it usesVirtualFree(base, addr, MEM_DECOMMIT)
to return the segments to the operating system. There is some hysteresis in returning segments to the operating system. Normally, MPS retains 256 KB of space, so it does not immediately need to re-map data from the operating system after unmapping data. The amount of hysteresis is configurable, but this is normally not necessary.
Memory accounting on Windows in complex. There is no single easy measure of the amount of physical memory that a process uses, because of shared objects, paging, and on-demand initialization of pages from the virtual memory system. The Private Bytes measure is possibly the best indication of the amount of physical memory the RIP has committed. Process Explorer can be configured to show this figure, as well as the amount of address space requested by the RIP (the Virtual Size). Windows Task Manager shows the Private Working Set as its memory figure, which is the amount of memory actually in-use by the RIP process.