gpt4 book ai didi

c++ - MFC分配大内存

转载 作者:行者123 更新时间:2023-11-28 03:24:57 25 4
gpt4 key购买 nike

有时我需要处理巨大的 PDF 文件,在这种情况下,我会在循环中使用一些新的运算符,这是一个非常大的循环,以至于将使用超过 10 GB 的内存。众所周知,我必须使用一些WIN API函数才能使用硬盘。但我不知道如何实现。谁能帮帮我?

这是一个代码片段:

CMyObject gg_data;
for(__int64 i = 0; i < up_limit(__int64); ++i)
{
//add new data to the PDF file
CCAry pData = new CCAry("myData");
gg_data.AddRef(pData);
}

//after the loop, save file and free memory so that no memory leaks occur...
//Caution: the "save" is a very expensive work, it will take several hours!!!
gg_data.save();

最佳答案

Memory mapped files是你想要的。这会将文件映射到内存的“缓冲区”中,操作系统会为您管理它,以便您可以像操作一大块 RAM 一样操作该文件。

关于c++ - MFC分配大内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14358891/

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