内存映射
内存映射是将磁盘上的某个文件或某个文件的一部分映射到应用程序地址空间的某个地址范围的一种机制。在随机访问大型文件或频繁访问小型文件时可使用内存映射。此外,内存映射还允许您使用标准的 MATLAB® 索引操作来访问文件数据。有关详细信息,请参阅内存映射概述。
函数
memmapfile | 创建文件的内存映射 |
主题
- 内存映射概述
内存映射是将磁盘上某文件的一部分或整个文件映射到应用程序地址空间内某个地址范围的一种机制。然后,应用程序可采用与访问动态内存相同的方法访问磁盘上的文件。与使用
fread
和fwrite
等函数相比,这会加快文件的读取和写入速度。 - Map File to Memory
Suppose you want to create a memory map for a file named
records.dat
, using thememmapfile
function. - Read from Mapped File
This example shows how to create two different memory maps, and then read from each of the maps using the appropriate syntax.
- Write to Mapped File
This example shows how to create three different memory maps, and then write to each of the maps using the appropriate syntax.
- Delete Memory Map
To clear a
memmapfile
object from memory, do any of the following: - Share Memory Between Applications
This example shows how to implement two separate MATLAB processes that communicate with each other by writing and reading from a shared file.