Questions tagged [mmap]

mmap is a POSIX-compliant Unix system call that maps files or devices into memory.

mmap() creates a new mapping in the virtual address space of the calling process.

https://en.wikipedia.org/wiki/Mmap

1936 questions
15
votes
1 answer

Understanding shared_memory in Python 3.8

I'm trying to understand some of shared_memory's operation. Looking at the source , it looks like the module uses shm_open() for UNIX environments, and CreateFileMapping \ OpenFileMapping on windows, combined with mmap. I understand from here, that…
Jay
  • 2,535
  • 3
  • 32
  • 44
15
votes
3 answers

how to memory map a huge matrix?

Suppose you got a huge (40+ GB) feature value (floating-point) matrix, rows are different features and columns are the samples/images. The table is precomputed column-wise. Then it is completely accessed row-wise and multi-threaded (each thread…
Trass3r
  • 5,858
  • 2
  • 30
  • 45
15
votes
2 answers

Memory Mapped files and atomic writes of single blocks

If I read and write a single file using normal IO APIs, writes are guaranteed to be atomic on a per-block basis. That is, if my write only modifies a single block, the operating system guarantees that either the whole block is written, or nothing at…
Martin Probst
  • 9,497
  • 6
  • 31
  • 33
15
votes
4 answers

Is there really no mremap in Darwin?

I'm trying to find out how to remap memory-mapped files on a Mac (when I want to expand the available space). I see our friends in the Linux world have mremap but I can find no such function in the headers on my Mac.…
Joe
  • 46,419
  • 33
  • 155
  • 245
15
votes
2 answers

use mmap in C to write into memory.

I want to use mmap() to create a file containing some integers. I want to write to this file by writing to memory. I know that the data in memory is binary format and hence the data in file will also be in binary. Can I use mmap for this purpose?…
parisa
  • 784
  • 1
  • 8
  • 27
15
votes
4 answers

How to share data between python processes without writing to disk

Helllo, I would like to share small amounts of data (< 1K) between python and processes. The data is physical pc/104 IO data which changes rapidly and often (24x7x365). There will be a single "server" writing the data and multiple clients reading…
RyanN
  • 740
  • 8
  • 20
15
votes
3 answers

Why does mmap() fail with permission denied for the destination file of a file copy program?

I'd like to give a try at copying the contents of a file over to another one by using memory mapped I/O in Linux via mmap(). The intention is to check by myself if that's better than using fread() and fwrite() and how would it deal with big files…
James Russell
  • 339
  • 1
  • 3
  • 12
14
votes
1 answer

Mmap DMA memory uncached: "map pfn ram range req uncached-minus got write-back"

I am mapping DMA coherent memory from kernel to user space. At user level I use mmap() and in kernel driver I use dma_alloc_coherent() and afterwards remap_pfn_range() to remap the pages. This basically works as I can write data to the mapped area…
Gbo
  • 161
  • 1
  • 5
14
votes
1 answer

Improving mmap memcpy file read performance

I have an application that sequentially reads data from a file. Some is read directly from a pointer to the mmaped file and other parts are memcpyed from the file to another buffer. I noticed poor performance when doing a large memcpy of all the…
Alex
  • 140
  • 6
14
votes
2 answers

Error: Could not mmap file: vmlinux

In a newly installed virtual machine I get this error when compiling the kernel for the x86 architecture: $ Could not mmap file: vmlinux $ make: *** [vmlinux] Error 1 It is the first time I see it. I have increased the size of…
user3018391
  • 141
  • 1
  • 4
14
votes
4 answers

Why does mmap fail on iOS?

I'm trying to use mmap to read and play audio files on iOS. It works fine for files up to about 400MB. But when I try a 500MB file, I get a ENOMEM error. char *path = [[[NSBundle mainBundle] pathForResource: @"test500MB" ofType: @"wav"]…
Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
13
votes
3 answers

How do I choose a fixed address for mmap?

mmap() can be optionally supplied with a fixed location to place the map. I would like to mmap a file and then have it available to a few different programs at the same virtual address in each program. I don't care what the address is, just as…
SoapBox
  • 20,457
  • 3
  • 51
  • 87
13
votes
2 answers

Can mmap and gzip collaborate?

I'm trying to figure how to use mmap with a gzip compressed file. Is that even possible ? import mmap import os import gzip filename = r'C:\temp\data.gz' file = gzip.open(filename, "rb+") size = os.path.getsize(filename) file =…
mab
  • 151
  • 1
  • 6
13
votes
4 answers

In a 64 bit process, will my mmap / malloc request ever be denied?

The address space for 64 bit addressing is absolutely huge. I have a program that will mmap several chunks of memory, each of the order of 100 - 500 MB. I will inevitably be remapping a few times, which may cause some fragmentation of available…
Joe
  • 46,419
  • 33
  • 155
  • 245
13
votes
1 answer

Does mmap return aligned pointer values

Does mmap() guarantee that the return values are aligned to the largest alignment on the system? i.e. is it guaranteed by the POSIX standard that mmap has to return pointer values that are multiples of alignof(std::max_align_t)? I was not able to…
Curious
  • 20,870
  • 8
  • 61
  • 146