Fernandez
Fernandez

Reputation: 501

Is there a memory mapping api on windows platform, just like mmap() on linux?

Is there an api to do memory mapping, just like

mmap()

on linux?

Upvotes: 50

Views: 53660

Answers (2)

Dan
Dan

Reputation: 13160

To memory map a file or to share memory, you can use CreateFileMapping as the other answer suggests.

But if you're using mmap to allocate pages (to write a memory allocator, for instance) the Windows equivalent is VirtualAlloc.

Upvotes: 1

Igor Skochinsky
Igor Skochinsky

Reputation: 25288

Depends on what exactly you want to use it for. If you want to map existing files into memory, that's supported with memory-mapped files. They can also be used to share memory between processes (use named mapping object with no underlying file). If you want to map physical memory, that's generally not supported from user mode, although there are some tricks.

Upvotes: 28

Related Questions