/* * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// 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.