gpt4 book ai didi

c++ - CreateFileMapping/MapViewOfFile 返回的共享内存数组是否初始化为零?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:28:26 24 4
gpt4 key购买 nike

只是想知道我是否正在像这样在 Windows 平台上创建共享内存阵列:

HANDLE hFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT, 0, 1024 * 4, _T("mySharedMemName"));
if(hFile)
{
VOID* pData = MapViewOfFile(hFile, FILE_MAP_ALL_ACCESS, 0, 0, 1024 * 4);

//Is 'pData' array initialized with zeros the first time the 'hFile' is used?
}

我第一次调用这段代码时,内存数组是否初始化为0?如果不是,如何使其初始化为零?

最佳答案

来自documentation :

The initial contents of the pages in a file mapping object backed by the operating system paging file are 0 (zero).

关于c++ - CreateFileMapping/MapViewOfFile 返回的共享内存数组是否初始化为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11067988/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com