网站首页  词典首页

请输入您要查询的函数:

 

术语 virtualallocexnuma
释义 VirtualAllocExNuma
语法:
C++
LPVOID WINAPI VirtualAllocExNuma(
__in HANDLE hProcess,
__in_opt LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flAllocationType,
__in DWORD flProtect,
__in DWORD nndPreferred
);
VirtualAllocExNuma功能
保留或提交在指定的进程的虚拟地址空间的内存区域,并指定为物理内存的NUMA节点。
参数
hProcess [in]
句柄的进程。函数分配在这一进程的虚拟地址空间的内存。
句柄必须有PROCESS_VM_OPERATION访问权。有关更多信息,请参见过程的安全性和访问权限。
lpAddress [中,可选]
指针,指定所需的起点区域的网页地址,您想分配。
如果您是保留内存,功能轮到这个地址的分配粒度最近的倍数。
如果您犯的内存已经预留,该函数发到这个地址最近的页面边界。要确定在主机上的页面大小和粒度的分配,使用的GetSystemInfo函数。
如果lpAddress为NULL,则函数确定如何分配该地区。
dwSize [in]
该内存区域的大小来分配,以字节为单位。
如果lpAddress为NULL,则函数轮dwSize到下一个页面边界。
如果lpAddress不是NULL,该函数分配的所有页面中包含由lpAddress到lpAddress的一个或更多的字节+ dwSize。这意味着,例如,一个2字节范围跨越1页边界导致函数分配两个网页。
flAllocationType [in]
内存分配的类型。此参数必须包含下列值之一。
ValueMeaning
MEM_COMMIT
0x1000Allocates物理存储在内存中,或在指定保留在磁盘上的内存页分页文件。该函数初始化内存为0。
为了保留和提交的网页在一个步骤,调用该函数MEM_COMMIT | MEM_RESERVE。
函数失败如果您尝试提交一个尚未被预留页面。由此产生的错误代码是ERROR_INVALID_ADDRESS。
企图犯下一个已经承诺不会导致函数失败页面。这意味着您可以提交首先确定每一页的页当前状态的承诺。
MEM_RESERVE
0x2000Reserves没有分配任何实际的物理存储在内存或磁盘上的分页文件的进程的虚拟地址空间范围。
您提交保留通过调用的函数再次MEM_COMMIT页。为了保留和提交的网页在一个步骤,调用该函数MEM_COMMIT | MEM_RESERVE。
其他的内存分配功能,如malloc和LocalAlloc,不能使用保留的内存,直到它已被释放。
MEM_RESET
0x80000Indicates的数据由lpAddress和dwSize指定的内存范围已不再感兴趣。该网页不应该读出或写入页面文件。但是,内存块将再次使用以后,因此不应该decommitted。此值不能用于任何其他值。
使用此值不保证范围与MEM_RESET将包含零操作。如果您想范围包含零,承诺解除的内存,然后再次作出它。
当您使用MEM_RESET,该函数忽略fProtect价值。但是,您仍然必须设置fProtect为有效保护的价值,如PAGE_NOACCESS。
该函数返回一个错误如果您使用MEM_RESET和范围的内存映射到一个文件中。甲共同的看法是唯一可以接受的,如果它映射到一个页面文件。
此参数还可以指定下列值所示。
ValueMeaning
MEM_LARGE_PAGES
0x20000000Allocates使用大内存页支持。
大小和对齐方式必须是大页的最低倍数。要获得此值,使用GetLargePageMinimum功能。
MEM_PHYSICAL
0x400000Reserves一个地址范围,可用于映射地址窗口扩展(AWE)的网页。
此值必须与MEM_RESERVE,没有其他值。
MEM_TOP_DOWN
0x100000Allocates在尽可能高的内存地址。
flProtect [in]
对于该地区的页面内存保护分配。如果网页被承诺,您可以指定任何内存保护常量之一。
保护属性指定的页面时,保护不能与分配时指定网页的冲突。
nndPreferred [in]
在NUMA节点在物理内存应该驻留。
返回值
如果函数成功,返回值是分配的页面地区基址。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
每一页都有一个关联的页面的状态。该VirtualAllocExNuma函数可以执行以下操作:
凯明地区保留的网页
储备区域自由页
同时保留和提交的免费网页地区
VirtualAllocExNuma不能保留保留网页。它可以提交一个已经承诺页面。这意味着您可以提交的页面范围,不论他们是否已经承诺,而功能也不会失败。
您可以使用VirtualAllocExNuma保留的网页块,然后作出进一步要求VirtualAllocExNuma实施从预留屏蔽个人网页。这使得一个进程,消耗体能储备不存储其虚拟地址空间范围,直到需要它。
如果lpAddress参数不是NULL,则函数使用lpAddress和dwSize参数来计算的页面区域分配。在整个的页面范围现状必须符合由参数指定的flAllocationType分配类型。否则,函数失败并没有的网页分配。这种兼容性要求,并不排除犯已经承诺页,见前面的列表。
由于VirtualAllocExNuma不分配任何物理页,它一定会成功与否的网页在该节点或在系统其他地方。物理页面分配的需求。如果首选的节点运行的网页,内存管理器将使用来自其他节点的网页。如果内存是调出,同样的过程时使用它带回英寸
若要执行动态生成的代码,使用VirtualAllocExNuma分配内存和VirtualProtectEx职能,授予PAGE_EXECUTE访问。
该VirtualAllocExNuma函数可用于保留在一个特定进程的虚拟地址空间的地址窗口扩展(AWE)的内存区域。这种内存区域可以被用来映射到的虚拟内存不足的应用程序所需的物理页。在MEM_PHYSICAL和MEM_RESERVE值必须设置在AllocationType参数。该MEM_COMMIT值不能被设置。该网页的保护必须设置为PAGE_READWRITE。
该VirtualFreeEx函数可以承诺解除一个坚定的网页,发布页面的存储,也可以同时承诺解除和释放一个坚定的页面。它也可以释放保留的网页,使其成为一个自由页面。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0600或更高版本。
实例
有关示例,请参见分配从NUMA节点内存。
要求:
client最低支持Vista
server最低支持 Windows Server 2008
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
内存管理功能
NUMA支持
虚拟内存函数
VirtualAllocEx
VirtualFreeEx
VirtualLock
VirtualProtect
VirtualQuery
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==VirtualAllocExNuma Function
Reserves or commits a region of memory within the virtual address space of the specified process, and specifies the NUMA node for the physical memory.
Syntax
C++
LPVOID WINAPI VirtualAllocExNuma(
__in HANDLE hProcess,
__in_opt LPVOID lpAddress,
__in SIZE_T dwSize,
__in DWORD flAllocationType,
__in DWORD flProtect,
__in DWORD nndPreferred
);
Parameters
hProcess [in]
The handle to a process. The function allocates memory within the virtual address space of this process.
The handle must have the PROCESS_VM_OPERATION access right. For more information, see Process Security and Access Rights .
lpAddress [in, optional]
The pointer that specifies a desired starting address for the region of pages that you want to allocate.
If you are reserving memory, the function rounds this address down to the nearest multiple of the allocation granularity.
If you are committing memory that is already reserved, the function rounds this address down to the nearest page boundary. To determine the size of a page and the allocation granularity on the host computer, use the GetSystemInfo function.
If lpAddress is NULL, the function determines where to allocate the region.
dwSize [in]
The size of the region of memory to be allocated, in bytes.
If lpAddress is NULL, the function rounds dwSize up to the next page boundary.
If lpAddress is not NULL, the function allocates all pages that contain one or more bytes in the range from lpAddress to lpAddress+dwSize. This means, for example, that a 2-byte range that straddles a page boundary causes the function to allocate both pages.
flAllocationType [in]
The type of memory allocation. This parameter must contain one of the following values.
ValueMeaning
MEM_COMMIT
0x1000Allocates physical storage in memory or in the paging file on disk for the specified reserved memory pages. The function initializes the memory to zero.
To reserve and commit pages in one step, call the function with MEM_COMMIT | MEM_RESERVE.
The function fails if you attempt to commit a page that has not been reserved. The resulting error code is ERROR_INVALID_ADDRESS.
An attempt to commit a page that is already committed does not cause the function to fail. This means that you can commit pages without first determining the current commitment state of each page.
MEM_RESERVE
0x2000Reserves a range of the process's virtual address space without allocating any actual physical storage in memory or in the paging file on disk.
You commit reserved pages by calling the function again with MEM_COMMIT. To reserve and commit pages in one step, call the function with MEM_COMMIT | MEM_RESERVE.
Other memory allocation functions, such as malloc and LocalAlloc , cannot use reserved memory until it has been released.
MEM_RESET
0x80000Indicates that data in the memory range specified by lpAddress and dwSize is no longer of interest. The pages should not be read from or written to the paging file. However, the memory block will be used again later, so it should not be decommitted. This value cannot be used with any other value.
Using this value does not guarantee that the range operated on with MEM_RESET will contain zeroes. If you want the range to contain zeroes, decommit the memory and then recommit it.
When you use MEM_RESET, the function ignores the value of fProtect. However, you must still set fProtect to a valid protection value, such as PAGE_NOACCESS.
The function returns an error if you use MEM_RESET and the range of memory is mapped to a file. A shared view is only acceptable if it is mapped to a paging file.

This parameter can also specify the following values as indicated.
ValueMeaning
MEM_LARGE_PAGES
0x20000000Allocates memory using large page support .
The size and alignment must be a multiple of the large-page minimum. To obtain this value, use the GetLargePageMinimum function.
MEM_PHYSICAL
0x400000Reserves an address range that can be used to map Address Windowing Extensions (AWE) pages.
This value must be used with MEM_RESERVE and no other values.
MEM_TOP_DOWN
0x100000Allocates memory at the highest possible address.

flProtect [in]
The memory protection for the region of pages to be allocated. If the pages are being committed, you can specify any one of the memory protection constants .
Protection attributes specified when protecting a page cannot conflict with those specified when allocating a page.
nndPreferred [in]
The NUMA node where the physical memory should reside.
Return Value
If the function succeeds, the return value is the base address of the allocated region of pages.
If the function fails, the return value is NULL. To get extended error information, call GetLastError .
Remarks
Each page has an associated page state . The VirtualAllocExNuma function can perform the following operations:
Commit a region of reserved pages
Reserve a region of free pages
Simultaneously reserve and commit a region of free pages
VirtualAllocExNuma cannot reserve a reserved page. It can commit a page that is already committed. This means you can commit a range of pages, regardless of whether they have already been committed, and the function will not fail.
You can use VirtualAllocExNuma to reserve a block of pages and then make additional calls to VirtualAllocExNuma to commit individual pages from the reserved block. This enables a process to reserve a range of its virtual address space without consuming physical storage until it is needed.
If the lpAddress parameter is not NULL, the function uses the lpAddress and dwSize parameters to compute the region of pages to be allocated. The current state of the entire range of pages must be compatible with the type of allocation specified by the flAllocationType parameter. Otherwise, the function fails and none of the pages is allocated. This compatibility requirement does not preclude committing an already committed page; see the preceding list.
Because VirtualAllocExNuma does not allocate any physical pages, it will succeed whether or not the pages are available on that node or elsewhere in the system. The physical pages are allocated on demand. If the preferred node runs out of pages, the memory manager will use pages from other nodes. If the memory is paged out, the same process is used when it is brought back in.
To execute dynamically generated code, use VirtualAllocExNuma to allocate memory and the VirtualProtectEx function to grant PAGE_EXECUTE access.
The VirtualAllocExNuma function can be used to reserve an Address Windowing Extensions (AWE) region of memory within the virtual address space of a specified process. This region of memory can then be used to map physical pages into and out of virtual memory as required by the application. The MEM_PHYSICAL and MEM_RESERVE values must be set in the AllocationType parameter. The MEM_COMMIT value must not be set. The page protection must be set to PAGE_READWRITE.
The VirtualFreeEx function can decommit a committed page, releasing the page's storage, or it can simultaneously decommit and release a committed page. It can also release a reserved page, making it a free page.
To compile an application that uses this function, define _WIN32_WINNT as 0x0600 or later.
Examples
For an example, see Allocating Memory from a NUMA Node .
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
Memory Management Functions
NUMA Support
Virtual Memory Functions
VirtualAllocEx
VirtualFreeEx
VirtualLock
VirtualProtect
VirtualQuery
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa366891(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:25:53