Win64的内存映射文件和锁定页面 [英] WIn64 memory mapped files and locking pages

查看:153
本文介绍了Win64的内存映射文件和锁定页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取数据的实时大量(4-8GB) - 不放弃任何数据。

I need to grab large amounts (4-8Gb) of data in realtime - without dropping any data.

旧的系统可能只是跟上数据写入到条带RAID阵列,但数据已变得越来越大,比磁盘快已经得到更快(!),所以我没有时间来访问磁盘。< BR> 新计划是切换到Win64上,安装RAM的手,传入的数据塞进一个缓冲区,然后写这一切在最后。

The old system could just about keep up with writing the data to a striped RAID array but the data has got bigger, faster than the disk have got faster (!) So I don't have time to access the disk.
The new plan is to switch to Win64, install LOTS of ram, stuff the incoming data into a buffer and then write it all at the end.

所以我在寻找:
一个Windows API的限制新的[]到物理内存并锁定页到物理内存,或者我只是禁用页面文件。

So I'm looking for:
A windows API that limits new[] to physical memory and locks pages into physical ram, or I just disable the pagefile.

或者我使用内存映射文件并强制进行同步在结束时,我关闭文件。是否有一个内存映射文件标志,prevents身后,直到我准备写?

Or I use memory mapped files and force a sync at the end when I close the file. Is there a memory mapped file flag that prevents a write behind until I am ready?

推荐答案

什么你必须做的就是超载运营商新的分配和自己锁定内存。

What you'll have to do is overload operator new and allocate and lock that memory yourself.

  1. 呼叫<一href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx">VirtualAlloc分配的内存块的。
  2. 呼叫<一href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366895%28v=vs.85%29.aspx">VirtualLock锁定这些页面的物理内存。请注意,有时很难说服窗口要做到这一点,但通常会工作,如果你有足够的RAM的方式更多,你已经设置的过程中适当的工作集大小使用<一个href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms686234%28v=vs.85%29.aspx">SetProcessWorkingSetSize.请注意,特殊的PROCESS_SET_QUOTA权限的用户帐户中的进程运行将需要
  1. Call VirtualAlloc to allocate your chunk of memory.
  2. Call VirtualLock to lock those pages to physical RAM. Note that it can sometimes be difficult to convince windows to do this, but will usually work if you have way more than enough RAM and you have set the process working set size appropriately using SetProcessWorkingSetSize. Note the special PROCESS_SET_QUOTA permission the user account your process is running under will need.

这篇关于Win64的内存映射文件和锁定页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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