释放内存映射内存 [英] Release Memory Mapped Memory

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

问题描述

我是内存映射文件较大(〜200GB)为一个区域/视图和顺序写入数据。时不时地,我执行的boost ::进程间:: mapped_region ::冲洗(最后,当前,FALSE)

I am memory mapping a large file (~200GB) into a single region/view and sequentially writing to it. Every now and then I perform a boost::interprocess::mapped_region::flush(last, current, false).

过了一会该过程使用了整个系统内存。其中,从我的理解,是正常的,因为它会被释放内存为其他处理请求的内存。

After a while the process uses up the entire system memory. Which, from what I understand, is normal as it will be releasing the memory as other process request memory.

这行之有效的Windows 8。然而,在Windows 7上运行它似乎并没有与驱动程序AJA视频卡发挥出色,并开始影响性能(IO丢弃数据包)。

This works well on Windows 8. However, running on Windows 7 it doesn't seem to play well with the drivers for AJA video cards and it starts affecting performance (dropping IO packets).

有没有什么办法可以强制Windows 7刷新存储到磁盘的部分(数据写入后,仅几秒钟有趣,记得我在整个文件写入顺序),以不能用了整个可用系统内存?

Is there any way I can force the Windows 7 to flush parts of the memory to disk (after the data is written it is only interesting for a few seconds, and remember I am writing sequentially through the entire file), as to not use up the entire available system memory?

推荐答案

法拉盛与复垦,IYAM无关。它只是确保脏页都写了(我想你还是需要一个磁盘同​​步,以确保它实际上/命中磁盘/)。

Flushing has nothing to with reclamation, IYAM. It just makes sure dirty pages are written out (I think you still need a disk sync to make sure it actually /hit the disk/).

所以,你正在寻找一种方式来取消映射。

So, you're looking for a way to unmap.

也许你可以使用像

当然,在一个更​​便携的时尚,你可能只是侥幸取消映射和重映射。如果访问的是纺纱硬盘和保持整个重映射的顺序,有可能不是一个性能损失(有可能是虽然,如果内核prefetched到的madvise例如,由于数据()或Windows等价物)

Of course, in a more portable fashion, you might just get away with unmapping and remapping. If the access is to spinning HDD and remains sequential across remaps, there might not be a performance penalty (there might be though, if the kernel prefetched data e.g. due to madvise() or the windows equivalent thereof)

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

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