C++/Win32 在虚拟内存中创建文件 [英] C++/Win32 Create a file in virtual memory

查看:46
本文介绍了C++/Win32 在虚拟内存中创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在虚拟内存中创建一个文件,我可以在它上面使用普通的文件函数,如 CreateFile、WriteFile 等吗?

How do I create a file in virtual memory and can I use normal file functions on it as CreateFile, WriteFile etc. ?

我正在尝试实现一个缓冲文件编写器类,但问题在于管理需要动态常量重新分配的缓冲区.

I am trying to implement a buffered file writer class, but the problem is managing a buffer that needs dynamic constant reallocation.

推荐答案

据我所知,你想要虚拟内存中的整个文件?但对我来说感觉有点困难,因此我有另一种解决方法.您可以使用 VirtualAllocExNuma 将您的文件加载到内存中并对其进行处理.因为虚拟内存是应该由操作系统保留但在在物理上,它分散在除 RAM 之外的不同非统一存储设备中.
它不是一个可以保存文件的文件系统,而且它的管理方式也很难追踪(至少对我而言!).

As far as I think,you want the whole file inside Virtual Memory? But it feels a little difficult to me, and thus I have got another workaround for it.You can use VirtualAllocExNuma to load your file in memory and work on it.Since Virtual Memory is that part of the memory which is just supposed to be retained by OS but in physically it is scattered around different Non Uniform memory devices besides RAM.
It is not a filesystem where you can save your files and how it is managed is also difficult to be traced(at least for me!).

VirtualAllocExNuma

在虚拟地址内保留或提交一个内存区域指定进程的空间,并为进程指定NUMA节点物理内存.

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.

这篇关于C++/Win32 在虚拟内存中创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆