// Memory reservation, commit, views, and placeholders. // // To be able to up-front reserve address space for the heap views, and later // multi-map the heap views to the same physical memory, without ever losing the // reservation of the reserved address space, we use "placeholders". // // These placeholders block out the address space from being used by other parts // of the process. To commit memory in this address space, the placeholder must // be replaced by anonymous memory, or replaced by mapping a view against a // paging file mapping. We use the later to support multi-mapping. // // We want to be able to dynamically commit and uncommit the physical memory of // the heap (and also unmap ZPages), in granules of ZGranuleSize bytes. There is // no way to grow and shrink the committed memory of a paging file mapping. // Therefore, we create multiple granule-sized page file mappings. The memory is // committed by creating a page file mapping, map a view against it, commit the // memory, unmap the view. The memory will stay committed until all views are // unmapped, and the paging file mapping handle is closed. // // When replacing a placeholder address space reservation with a mapped view // against a paging file mapping, the virtual address space must exactly match // an existing placeholder's address and size. Therefore we only deal with // granule-sized placeholders at this layer. Higher layers that keep track of // reserved available address space can (and will) coalesce placeholders, but // they will be split before being used.
if (!res) {
fatal_error("Failed to unreserve memory", addr, size);
}
}
HANDLE ZMapper::create_paging_file_mapping(size_t size) { // Create mapping with SEC_RESERVE instead of SEC_COMMIT. // // We use MapViewOfFile3 for two different reasons: // 1) When committing memory for the created paging file // 2) When mapping a view of the memory created in (2) // // The non-platform code is only setup to deal with out-of-memory // errors in (1). By using SEC_RESERVE, we prevent MapViewOfFile3 // from failing because of "commit limit" checks. To actually commit // memory in (1), a call to VirtualAlloc2 is done.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.