内存映射文件可以有多大? [英] How big can a memory-mapped file be?

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

问题描述

什么限制了内存映射文件的大小?我知道它不能大于未分配地址空间的最大连续块,并且应该有足够的可用磁盘空间.但是还有其他限制吗?

What limits the size of a memory-mapped file? I know it can't be bigger than the largest continuous chunk of unallocated address space, and that there should be enough free disk space. But are there other limits?

推荐答案

您太保守了:内存映射文件可能大于地址空间.内存映射文件的视图受操作系统内存限制的限制,但这只是您一次要查看的文件的一部分. (从技术上讲,我认为您可以一次映射文件的不连续部分的多个视图,因此,除了开销和页面长度限制之外,这只是限制了您正在查看的总字节数.您可以查看字节数[0到1024]和字节[2 40 到2 40 + 1024],带有两个单独的视图.)

You're being too conservative: A memory-mapped file can be larger than the address space. The view of the memory-mapped file is limited by OS memory constraints, but that's only the part of the file you're looking at at one time. (And I guess technically you could map multiple views of discontinuous parts of the file at once, so aside from overhead and page length constraints, it's only the total # of bytes you're looking at that poses a limit. You could look at bytes [0 to 1024] and bytes [240 to 240 + 1024] with two separate views.)

在MS Windows中,查看 MapViewOfFile 功能.有效地采用64位文件偏移和32位长度.

In MS Windows, look at the MapViewOfFile function. It effectively takes a 64-bit file offset and a 32-bit length.

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

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